rust boilerplate

This commit is contained in:
Michael Matthews 2021-07-12 16:58:00 -04:00
parent 8831641bce
commit 6384928884
12 changed files with 1292 additions and 512 deletions

6
.gitignore vendored
View File

@ -1,3 +1,3 @@
node_modules/
.DS_Store
/src/config.json
# Added by cargo
/target

1272
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

11
Cargo.toml Normal file
View File

@ -0,0 +1,11 @@
[package]
name = "Osselbot"
version = "0.1.0"
authors = ["Michael Matthews <michaeldylanmatthews@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serenity = "0.10"

View File

@ -1,28 +1,11 @@
# Osselbot
A bot that is kinda stupid, but it works surprisingly well
![Node.js CI](https://github.com/Technicolor-creamsicle/Osselbot/workflows/Node.js%20CI/badge.svg)
A rusty bot that's kinda stupid, but it works surprisingly well
**THIS BOT REQUIRES HEAVY MODIFICATION TO WORK ON OTHER SERVERS!**
**NPM PACKAGE IS NO LONGER MAINTAINED**
Example config.js to be placed in /src
```json
{
"token" : "API KEY",
"prefix": "?",
"verbalabuse": [
"Quotes",
"to insult.",
"your members."
]
}
```
---
# Contributing
If your a member of civilians all partying then talk to @Technicolor Creamsicle#0773
If your a member of civilians all partying then talk to @Technicolor Creamsicle#0773 or @Gamma#0753
This code follows the Google JS specs for code formatting.
If you use the WebStorm IDE this will automatically be applied.

View File

@ -1 +0,0 @@
# Welcome to the osselbot help docs

125
npm-shrinkwrap.json generated
View File

@ -1,125 +0,0 @@
{
"name": "@technicolor-creamsicle/osselbot",
"version": "2.1.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@discordjs/collection": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.5.tgz",
"integrity": "sha512-CU1q0UXQUpFNzNB7gufgoisDHP7n+T3tkqTsp3MNUkVJ5+hS3BCvME8uCXAUFlz+6T2FbTCu75A+yQ7HMKqRKw=="
},
"@discordjs/form-data": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
"integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
},
"abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
"requires": {
"event-target-shim": "^5.0.0"
}
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"requires": {
"delayed-stream": "~1.0.0"
}
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
"discord.js": {
"version": "12.2.0",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.2.0.tgz",
"integrity": "sha512-Ueb/0SOsxXyqwvwFYFe0msMrGqH1OMqpp2Dpbplnlr4MzcRrFWwsBM9gKNZXPVBHWUKiQkwU8AihXBXIvTTSvg==",
"requires": {
"@discordjs/collection": "^0.1.5",
"@discordjs/form-data": "^3.0.1",
"abort-controller": "^3.0.0",
"node-fetch": "^2.6.0",
"prism-media": "^1.2.0",
"setimmediate": "^1.0.5",
"tweetnacl": "^1.0.3",
"ws": "^7.2.1"
}
},
"event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
},
"mime-db": {
"version": "1.44.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
"integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg=="
},
"mime-types": {
"version": "2.1.27",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz",
"integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
"requires": {
"mime-db": "1.44.0"
}
},
"n": {
"version": "6.6.0",
"resolved": "https://registry.npmjs.org/n/-/n-6.6.0.tgz",
"integrity": "sha512-Yk2z0OQKDCmDyBHltJRg2RsxPsdc2DHcM8fFN21j1rzqior+FifdqhvcbZ+k00EgiSvR6p8+s9whWLwvzSeqcw=="
},
"node-fetch": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
},
"parse-ms": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz",
"integrity": "sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA=="
},
"pretty-ms": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-6.0.1.tgz",
"integrity": "sha512-ke4njoVmlotekHlHyCZ3wI/c5AMT8peuHs8rKJqekj/oR5G8lND2dVpicFlUz5cbZgE290vvkMuDwfj/OcW1kw==",
"requires": {
"parse-ms": "^2.1.0"
}
},
"prism-media": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.2.tgz",
"integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw=="
},
"setimmediate": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
"integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
},
"tweetnacl": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
"integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
},
"ws": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz",
"integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w=="
}
}
}

View File

@ -1,7 +0,0 @@
{
"folders": [
{
"path": "."
}
]
}

View File

@ -1,36 +0,0 @@
{
"name": "@technicolor-creamsicle/osselbot",
"version": "2.1.2",
"description": "A discord bot on Discord.js",
"main": "index.js",
"dependencies": {
"discord.js": "^12.1.1",
"n": "^6.6.0",
"node-fetch": "^2.6.0",
"pretty-ms": "^6.0.1"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
},
"bin": {
"osselbot": "./src/index.js"
},
"files": [
"/src/"
],
"devDependencies": {},
"scripts": {
"test": "node --trace-warnings ./src/index.js --TEST",
"start": "node ./src/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Technicolor-creamsicle/Osselbot.git"
},
"author": "Alex Technicolor <technicolor@2a03.party> (http://technicolor.2a03.party)",
"license": "SEE LICENSE IN LICENCE",
"bugs": {
"url": "https://github.com/Technicolor-creamsicle/Osselbot/issues"
},
"homepage": "https://technicolor.2a03.party/bot"
}

View File

@ -1 +0,0 @@
{"quotes":["you can add quotes by running ?quote add <person> Quote goes here","techt parm arm zarm","<@!258325046869622785> I HATE JS."]}

View File

@ -1,9 +0,0 @@
{
"COMMENT": "THIS IS A CONFIG FOR TESTING THE BOT",
"token" : "THIS IS AN API TOKEN",
"prefix": "?",
"verbalabuse": [
"THIS IS MEAN"
]
}

View File

@ -1,311 +0,0 @@
#!/usr/bin/env node
// These are so I remember stuff
// Load up the libraries
const Discord = require('discord.js');
const prettyMilliseconds = require('pretty-ms');
const fs = require('fs');
const homedir = require('os').homedir;
const info = require('../package.json');
// Imports config file from the src dir.
const config = require('./config.json');
// This is making a client for discord
const client = new Discord.Client();
// Stores the last quote
let last_quote;
function activity() {
//This function sets a status for the bot currently it is set to Do Not
// Disturb and "LISTENING to USERS of you, why do I do this to myself?"
client.user.setPresence({
activity: {
name: `${client.users.cache.size} of you, why do I do this to myself?`,
type: 'LISTENING',
},
status: 'dnd',
}).then(() => {
});
}
client.on('ready', () => {
// This event will run if the bot starts, and logs in, successfully.
// noinspection LongLine
console.log(
`Bot has started, with ${client.users.cache.size} users, in \
${client.channels.cache.size} channels of ${client.guilds.cache.size} guilds.`);
activity();
});
//Updates people count
client.on('guildMemberAdd', member => {
console.log(`New member joined: ${member.nickname} (id: ${member.id}).`);
activity();
});
client.on('guildMemberRemove', member => {
console.log(` member left: ${member.nickname} (id: ${member.id}).`);
activity();
});
setInterval(activity, 300000);
////// ACTUAL MESSAGE PROCESSING
client.on('message', async message => {
//stops bots from activating the Osselbot
//Message processing
// noinspection SpellCheckingInspection
if (message.content.toLowerCase().
includes('nigg' || 'negro' || 'niglet' || 'fag' || 'f4g' || 'n1gg' ||
'gg3r')) {
await message.delete();
return message.reply(
`Listen here cum-sock we dont appreciate that here ${message.member}.\
If you gonna be like that you may just well end up in the JAR and we \
all know how that ends...`);
}
// Reacts to messages with UwU
if (message.content.toLowerCase().includes('uwu')) await message.react(
'741755736417108071');
if (message.author.bot) return;
if (message.content.indexOf(config.prefix) !== 0) return;
// Here we separate our "command" name, and our "arguments" for the command.
// e.g. if we have the message "+say Is this the real life?" , we'll get the
// following:
// command = say
// args = ["Is", "this", "the", "real", "life?"]
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////COMMAND TIME////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
if (command === 'stats') {
let embed = new Discord.MessageEmbed().setTitle('Stats').
setAuthor('Osselbot',
'https://cdn.discordapp.com/attachments/597814181084921866' +
'/711843993914310656/animated-beach-balls-29.gif').
setColor(0x195080).
setDescription(`\
**Stats for 0SSELB0T** \n \
**Uptime:** ${prettyMilliseconds(client.uptime)} \n \
**Started at:** ${client.readyAt} \n \
**People:** ${client.users.cache.size}`).
setFooter(`osselbot v${info.version} run version for full info`);
return message.channel.send(embed);
}
//////////////////////////////////////////////////////////////////////////////
if (command === 'ping') {
// Calculates ping between sending a message and editing it, giving a
// nice round-trip latency.
const m = await message.channel.send('Ping?');
await m.edit('Pong! Latency is`' + client.ws.ping + '` ms');
}
//HOW QUOTEABLE
if (command === 'psych') {
return message.channel.send(
'Rules for finding a psychopath: \n1. Favorite color is orange \n2.' +
' Likes the left burners, worse if its top left\n3. Calls pizza' +
' sauce/tomato sauce gravy\n4. Doesnt like salad\n5.' +
' Likes country music\n6. Makes hot chocolate with water\n7. Likes' +
' black licorice');
}
if (command === 'ask') {
return message.channel.send(
'Dont Ask, Just ask!\n https://iki.fi/sol/dontask.html');
}
if (command === 'simp') {
if (!message.member.roles.cache.some(r => [
'Admin',
'Moderator',
'Botmeister'].includes(r.name)))
return message.reply('Sorry, you don\'t have permissions to use this!');
let embed = new Discord.MessageEmbed().setTitle('SIMP Alert').
setURL('https://www.youtube.com/watch?v=c3m4Q07TkMk').
setColor(0x195080).
setDescription('__**ALERT**__ SIMP detected!').
setImage(
'https://vignette.wikia.nocookie.net/disney/images/6/64/' +
'Kronk_.jpg/revision/latest?cb=20160720194635').
setTimestamp();
await message.channel.send({embed});
}
if (command === 'squad') {
let min = Math.ceil(0);
let max = Math.floor(11);
//The maximum is exclusive and the minimum is inclusive
let rate = Math.floor(Math.random() * (max - min) + min);
return message.reply(`The squad rates this ${rate} out of 10`);
}
if (command === 'magic') {
return message.channel.send(
'Do you believe in magic in a young girl\'s heart\nHow the music can' +
' free her, whenever it starts \nAnd it\'s magic, if the music is' +
' groovy\nIt makes you feel happy like an old-time movie\nI\'ll tell' +
' you about the magic, and it\'ll free your soul\nBut it\'s like ' +
'trying to tell a stranger bout \'rock and roll\'');
}
if (command === 'help') {
return message.reply('https://technicolor.2a03.party/osselbot/');
}
if (command === 'fix') {
if (message.member.roles.cache.some(
r => ['Ally of the Order'].includes(r.name))) {
return message.channel.send('I guess it\'s my fault will fix.');
}
return;
}
if (command === 'va') {
//The maximum is exclusive and the minimum is inclusive
let num = Math.floor(Math.random() * (config.verbalabuse.length + 1));
return message.reply(`${config.verbalabuse[num]}`);
}
////////////////////////////////////////////////////////////////////////////////
if (command === 'say') {
// makes the bot say something and delete the message. As an example,
// it's open to anyone to use.To get the "message" itself we join the `args`
// back into a string with spaces:
const sayMessage = args.join(' ');
if (message.member.roles.cache.some(r => [
'Admin',
'Mods',
'Member of the Order',
'Botmeister',
'Ally of the Order',
'say'].includes(r.name))) {
if (message.content.includes('@')) {
return message.reply('haha no');
}
// Then we delete the command message (sneaky, right?). The catch just
// ignores the error with a cute smiley thing.
message.delete().catch(() => {
});
// And we get the bot to say the thing:
return message.channel.send(sayMessage);
}
}
////////////////////////////////////////////////////////////////////////////////
if (command === 'quote') {
let quotes = require(`${homedir}/quotes.json`);
let quoteadd = '';
let selector;
try {
selector = args[0].toLowerCase();
} catch (err) {
let length = quotes.quotes.length;
let quotesend = 0;
function choose() {
quotesend = Math.floor(Math.random() * (length));
console.log(quotesend);
if (last_quote === quotesend) choose();
}
choose();
last_quote = quotesend;
return message.channel.send(`${quotes.quotes[quotesend]}`);
}
if (selector === 'add') {
args.shift();
//This does logic to make it from an array to a nice string.
quoteadd = args.join(' ');
quotes.quotes.push(quoteadd);
fs.writeFile(`${homedir}/quotes.json`, JSON.stringify(quotes, null, 2),
(err) => {
if (err) return message.reply('Something went wrong');
client.channels.cache.get('712084662033580064').
send(
`${message.member} has submitted \`${quoteadd}\` to the
quote repository`);
return message.reply('Quote added to repository');
});
} else {
return message.reply(
'you can add quotes by running `?quote add <person> Quote goes here`')
}
}
////////////////////////////////////////////////////////////////////////////////
if (command === 'version') {
return message.channel.send(`\`\`\`\
________________________________________\n \
< @technicolor-creamsicle/osselbot@v${info.version}>\n \
----------------------------------------\n \
\\ ^__^\n \
\\ (oo)\\_______\n \
(__)\\ )\\/\\\n \
||----w |\n \
|| ||\n \
\`\`\``);
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////DEFCON//////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
if (command === 'defcon') {
//5 levels till ban
if (!message.member.roles.cache.some(r => [
'Admin'].includes(r.name)))
return message.reply('Sorry, you don\'t have permissions to use this!');
else {
let member = message.mentions.members.first();
let role;
switch (parseInt(args[1], 10)) {
case 5:
role = message.guild.roles.cache.find(
role => role.name === `DEFCON 5`);
await member.roles.add(role);
break;
case 4:
role = message.guild.roles.cache.find(
role => role.name === `DEFCON 4`);
await member.roles.add(role);
break;
case 3:
role = message.guild.roles.cache.find(
role => role.name === `DEFCON 3`);
await member.roles.add(role);
break;
case 2:
role = message.guild.roles.cache.find(
role => role.name === `DEFCON 2`);
await member.roles.add(role);
break;
case 1:
role = message.guild.roles.cache.find(
role => role.name === `DEFCON 1`);
await member.roles.add(role);
break;
default:
return message.reply(
`DEFCON not set is ${args[1]} a number between 1-5?`);
}
return message.reply(
`\n**DEFCON** level set to DEFCON ${args[1]}\nGod Bless their souls`);
}
}
});
if (process.argv.slice(2).includes('--TEST')) {
console.log('Test Pass!');
process.exit(0);
}
//Logging in the bot
client.login(config.token).then(() => {
console.log('Logged in');
});

4
src/main.rs Normal file
View File

@ -0,0 +1,4 @@
#![allow(non_snake_case)]
fn main() {
println!("Hello, world!");
}