Migrate bot-token and ownerid to dotenv

This commit is contained in:
IDeletedSystem64 2022-08-02 23:53:10 -05:00
parent 0f78055a66
commit cb1eb0a5bd
8 changed files with 16 additions and 12 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

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

View File

@ -32,7 +32,7 @@ module.exports = {
{ name: '<:anitrox:831193012699791361> Bot Information', value: '** **' },
{ name: 'Bot Name', value: `${client.user.tag}`, 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: 'Version', value: config.build, inline: true },
{ name: ':gear: Bot Process Information', value: '** **' },

View File

@ -5,7 +5,7 @@ module.exports = {
name: require('path').parse(__filename).name,
description: 'Reloads a command',
options: [...Array(10).keys()].map(i => ({
name: `option${i + 1}`,
name: `option${i + 0}`,
description: 'Another option',
required: i === 0,
type: Constants.ApplicationCommandOptionTypes.STRING
@ -20,7 +20,7 @@ module.exports = {
},
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());
let returnMessage = '';

View File

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

View File

@ -13,7 +13,7 @@ module.exports = {
},
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}`);
await channel.send({
embeds: [{

View File

@ -1,7 +1,5 @@
{
"prefix": "n!",
"token": "IM SO EXCITED ABOUT BURGER",
"ownerID": "MY FAVORITE COLOR IS TWELVE",
"release": "Stable Release",
"build": "1.3",
"footerTxt": "Anitrox, made with <3 by IDeletedSystem64 | 2018-2022",

View File

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