Update PTB to 1.3ptb_8.3.22

Refactor Help Command
Migrate the ownerID and bot token to dotenv
Change ping locations
Update documentation to support the configuration changes
This commit is contained in:
Sophie Marie 2022-08-03 00:04:37 -05:00 committed by GitHub
commit de90322304
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 58 additions and 58 deletions

3
.env.example Normal file
View file

@ -0,0 +1,3 @@
TOKEN="EVERYTHINGS SO FCKED AND IM TIRED OF BEING SCARED"
OWNERID="SO LETS GET OUT AND FCK UP EQUESTRIA"
# Do !!NOT!! share this file once filled out with anybody, Doing so can leak your Bot Token which will give anyone access to your bot!

View file

@ -7,7 +7,8 @@ Node.JS: 16
npm: 6.14 npm: 6.14
# Let's get this ~~party~~ bot started! # Let's get this ~~party~~ bot started!
For first time start up, You will need to run ``npm install`` to install the needed npm packages. For first time start up, You will need to run ``npm install`` to install the needed npm packages.
Afterwards fill out the ``config-example.json`` and rename it to ``config.json``, then just run ``node start.js`` (or ``./start.js`` on Linux)! Afterwards fill out the ``.env.example`` and ``config-example.json`` and then rename them to ``.env`` and ``config.json``, then just run ``node start.js`` (or ``./start.js`` on Linux)!
<br>
⚠️ If you don't specify the Owner ID, Some commands such as the bot controls will be unusable! ⚠️ If you don't specify the Owner ID, Some commands such as the bot controls will be unusable!
# Support # Support
Support is available on the [Discord Server!](discord.gg/5nQtMNpf43), or @ me on [Twitter!](twitter.com/IDeleteSystem64); Support is available on the [Discord Server!](discord.gg/5nQtMNpf43), or @ me on [Twitter!](twitter.com/IDeleteSystem64)

View file

@ -1,28 +0,0 @@
# Anitrox Command List
<> = Optionable
<br>
[] = Required
|Command|Arguments |Description |
|-------|----------|------------|
|Help |none |Help? Help!!|
|8ball |[Question]|Ask a question, Any question! |
|avatar |\<Member\> |Get a users beautiful avatar |
|bonk |[Member] | Bonk, no horny. |
|cheese |\<Member\>| Cheese.|
|cuddle |[Member] | Cuddle someone! |
|choose |[Option1] <br> [Option2] <br> [and so on] | Choose from a list of choices, as many as you want!
|hug |[Member] | Hug someone! |
|info |none | Information about the bot and host.
|invite |none | Invite Anitrox to your server!
|kiss |[Member] | Kiss someone! |
|leskiss|[Member] | Lesbain kiss (Suggested by Emi)
|lick |[Member] | Did you just lick me!?
|nom |[Member] | Nom someone or something
|opensource|none | Source code for Anitrox
|pat |[Member] | Pat someone!
|ping |none | Ping Elon Musk! or Mars! nah jk, Discord.
|poke |[Member] | Poke someone!
|slap |[Member] | Slap someone :(
|snuggle|[Member] | Snuggle someone!
|uinfo |[Member] | Information about an user

View file

@ -21,7 +21,7 @@ module.exports = {
}, },
handle (client, config, user, code) { handle (client, config, user, code) {
if (user.id === config.ownerID) { if (user.id === process.env.OWNERID) {
try { try {
const evaled = inspect(eval(code)); const evaled = inspect(eval(code));
// await message.channel.send(evaled, { code: 'xl' }); // await message.channel.send(evaled, { code: 'xl' });

View file

@ -1,28 +1,44 @@
const { Constants } = require('discord.js');
module.exports = { module.exports = {
name: require('path').parse(__filename).name, name: require('path').parse(__filename).name,
description: 'Get help on anything from commands, to what the bot does! just not your homework..', description: 'Get help on anything from commands, to what the bot does! just not your homework..',
options: [{ options: [{
name: '<Command>', name: 'help',
description: 'View Information about this command', description: 'View Information about this command',
required: false required: false,
type: Constants.ApplicationCommandOptionTypes.STRING
}], }],
async parseMessage (client, config, message, args) { async parseMessage (client, config, message, args) {
await message.channel.send(this.handle(client, config, message.author, args)); await message.channel.send(this.handle(client, config, message.author, args[0]));
}, },
async parseInteraction (client, config, interaction) { async parseInteraction (client, config, interaction) {
await interaction.reply(this.handle(client, config, interaction.user)); await interaction.reply(this.handle(client, config, interaction.user, interaction.options.getString('help')));
}, },
handle (client, config, user, args) { handle (client, config, user, command) {
if (!args[0]) { if (!command) {
return client.generateErrorMessage('Note to self: Design default help embed.', user.displayAvatarURL()); return {
embeds: [{
title: `:question: SEYMOUR! THE ${client.user.username} IS ON FIRE!`,
description: `Run ${config.prefix}help for more information on each command.`,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
},
fields: [
{ name: 'Commands', value: client.commands.map(command => command.name).join('\n') }
]
}]
};
} }
const cmdName = args[0].toLowerCase(); // const cmdName = args[0].toLowerCase();
const cmdName = command;
const cmd = client.commands.get(cmdName); const cmd = client.commands.get(cmdName);
console.log(cmd.options.map(option => option.required));
if (!cmd) { if (!cmd) {
return client.generateErrorMessage(`${cmdName} is not a valid command! Run ${config.prefix}help for a command list.`); return client.generateErrorMessage(`${cmdName} is not a valid command! Run ${config.prefix}help for a command list.`);
} }
@ -39,8 +55,8 @@ module.exports = {
{ name: 'Command Name', value: `${cmdName}`, inline: true }, { name: 'Command Name', value: `${cmdName}`, inline: true },
{ name: 'Command Description', value: cmd.description, inline: true }, { name: 'Command Description', value: cmd.description, inline: true },
{ name: 'Command Options', value: cmd.options.map(option => option.name).join('\n') || 'None', inline: true }, { name: 'Command Options', value: cmd.options.map(option => option.name).join('\n') || 'None', inline: true },
{ name: 'Command Option Description', value: cmd.options.map(option => option.description).join('\n') || 'None', inline: true }, { name: 'Command Option Description', value: cmd.options.map(option => option.description) || 'None', inline: true }
{ name: 'Option Legend', value: '[Option] REQUIRED\n<Option> OPTIONAL' } // { name: 'Command Option Required?', value: cmd.options.map(option => option.required) ? 'Yes' : 'No' }
] ]
}] }]
}; };

View file

@ -32,7 +32,7 @@ module.exports = {
{ name: '<:anitrox:831193012699791361> Bot Information', value: '** **' }, { name: '<:anitrox:831193012699791361> Bot Information', value: '** **' },
{ name: 'Bot Name', value: `${client.user.tag}`, inline: true }, { name: 'Bot Name', value: `${client.user.tag}`, inline: true },
{ name: 'Bot ID', value: `${client.user.id}`, inline: true }, { name: 'Bot ID', value: `${client.user.id}`, inline: true },
{ name: 'Bot Owner', value: isNaN(config.ownerID) ? "Owner didn't set an OwnerID :(" : client.users.cache.get(config.ownerID).username, inline: true }, { name: 'Bot Owner', value: isNaN(process.env.OWNERID) ? "Owner didn't set an OwnerID :(" : client.users.cache.get(process.env.OWNERID).username, inline: true },
{ name: 'Release Type', value: config.release, inline: true }, { name: 'Release Type', value: config.release, inline: true },
{ name: 'Version', value: config.build, inline: true }, { name: 'Version', value: config.build, inline: true },
{ name: ':gear: Bot Process Information', value: '** **' }, { name: ':gear: Bot Process Information', value: '** **' },

View file

@ -5,7 +5,7 @@ module.exports = {
name: require('path').parse(__filename).name, name: require('path').parse(__filename).name,
description: 'Reloads a command', description: 'Reloads a command',
options: [...Array(10).keys()].map(i => ({ options: [...Array(10).keys()].map(i => ({
name: `option${i + 1}`, name: `option${i + 0}`,
description: 'Another option', description: 'Another option',
required: i === 0, required: i === 0,
type: Constants.ApplicationCommandOptionTypes.STRING type: Constants.ApplicationCommandOptionTypes.STRING
@ -20,7 +20,7 @@ module.exports = {
}, },
handle (client, config, user, args) { handle (client, config, user, args) {
if (user.id === config.ownerID) { if (user.id === process.env.OWNERID) {
if (!args.length) return client.generateErrorMessage('You forgot to provide anything to reload, you pillock', user.displayAvatarURL()); if (!args.length) return client.generateErrorMessage('You forgot to provide anything to reload, you pillock', user.displayAvatarURL());
let returnMessage = ''; let returnMessage = '';

View file

@ -13,9 +13,9 @@ module.exports = {
}, },
async handle (client, config, user, channel) { async handle (client, config, user, channel) {
if (user.id === config.ownerID) { if (user.id === process.env.OWNERID) {
const embeds = [{ const embeds = [{
title: '<a:AnitroxWorking:697147309531594843> Restart Bot', title: '<a:AnitroxWorking:997565411212144730> Restart Bot',
description: 'Restarting Anitrox...', description: 'Restarting Anitrox...',
color: 9442302, color: 9442302,
footer: { footer: {
@ -27,11 +27,11 @@ module.exports = {
const response = await channel.send({ embeds }); const response = await channel.send({ embeds });
try { try {
client.destroy(); client.destroy();
await client.login(config.token); await client.login(process.env.TOKEN);
console.log('[SYSTEM] [INFO] Restarted successfully!'); console.log('[SYSTEM] [INFO] Restarted successfully!');
await response.edit({ await response.edit({
embeds: [{ embeds: [{
title: '<a:AnitroxWorking:697147309531594843> Restart Bot', title: ':white_check_mark: Restart Bot',
description: 'Restarted!', description: 'Restarted!',
color: 9442302, color: 9442302,
footer: { footer: {

View file

@ -13,12 +13,12 @@ module.exports = {
}, },
async handle (client, config, user, channel) { async handle (client, config, user, channel) {
if (user.id === config.ownerID) { if (user.id === process.env.OWNERID) {
console.log('[SYSTEM] [INFO] ' + `The bot is going down for shut down. \nShutdown requested by ${user.username}`); console.log('[SYSTEM] [INFO] ' + `The bot is going down for shut down. \nShutdown requested by ${user.username}`);
await channel.send({ await channel.send({
embeds: [{ embeds: [{
title: '**Shut down the bot**', title: '**Shut down the bot**',
description: '<a:AnitroxWorking:697147309531594843> **Shutting Down...**', description: '<a:AnitroxWorking:997565411212144730> **Shutting Down...**',
color: 9442302, color: 9442302,
footer: { footer: {
icon_url: user.displayAvatarURL(), icon_url: user.displayAvatarURL(),

View file

@ -1,9 +1,7 @@
{ {
"prefix": "n!", "prefix": "n!",
"token": "IM SO EXCITED ABOUT BURGER",
"ownerID": "MY FAVORITE COLOR IS TWELVE",
"release": "Stable Release", "release": "Stable Release",
"build": "1.2.2", "build": "1.3",
"footerTxt": "Anitrox, made with <3 by IDeletedSystem64 | 2018-2022", "footerTxt": "Anitrox, made with <3 by IDeletedSystem64 | 2018-2022",
"sandbox": { "sandbox": {
"enabled": false, "enabled": false,
@ -37,8 +35,15 @@
"127.0.0.1", "127.0.0.1",
"Sophie's computer", "Sophie's computer",
"Mars", "Mars",
"Elon Musk", "Netro Corporation",
"TMC Software" "System64 Technologies",
"myself",
"Twilight Sparkle",
"the Pokemon Center",
"Who asked?",
"you",
"your mother"
], ],
"answers": [ "answers": [
"Heck no!", "Heck no!",

View file

@ -3,7 +3,7 @@
const fs = require('fs'); const fs = require('fs');
const Discord = require('discord.js'); const Discord = require('discord.js');
const config = require('./config.json'); const config = require('./config.json');
require('dotenv').config();
console.log('Starting!'); console.log('Starting!');
const client = new Discord.Client({ intents: config.intents.map(intent => eval(`Discord.Intents.FLAGS.${intent}`)) }); const client = new Discord.Client({ intents: config.intents.map(intent => eval(`Discord.Intents.FLAGS.${intent}`)) });
@ -14,6 +14,7 @@ fs.readdirSync('./commands')
const command = require(`./commands/${file}`); const command = require(`./commands/${file}`);
client.commands.set(command.name, command); client.commands.set(command.name, command);
}); });
// Create a collection using those command files
fs.readdirSync('./events') fs.readdirSync('./events')
.filter(file => file.endsWith('.js')) .filter(file => file.endsWith('.js'))
@ -21,6 +22,7 @@ fs.readdirSync('./events')
.forEach(({ once, event, listener }) => { .forEach(({ once, event, listener }) => {
client[once ? 'once' : 'on'](event, listener(client, config)); client[once ? 'once' : 'on'](event, listener(client, config));
}); });
// Create listeners from the event files.
client.generateErrorMessage = (errorMsg, avatarURL) => ({ client.generateErrorMessage = (errorMsg, avatarURL) => ({
embeds: [{ embeds: [{
@ -39,4 +41,5 @@ client.generateErrorMessage = (errorMsg, avatarURL) => ({
}] }]
}); });
client.login(config.token); client.login(process.env.TOKEN);
// Login to Discord!