diff options
| author | 8cy <[email protected]> | 2020-07-07 03:55:21 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-07-07 03:55:21 -0700 |
| commit | 385b0960abdc8bb13172330a973dafd56560cf8d (patch) | |
| tree | 86e85d23404a5170ffbf870a6faeba77b3430e0e /src/bot.ts | |
| parent | add fanart for emma :star2: (diff) | |
| download | dep-core-385b0960abdc8bb13172330a973dafd56560cf8d.tar.xz dep-core-385b0960abdc8bb13172330a973dafd56560cf8d.zip | |
big cool :star:
- add commenting to bot.ts
- add types to most of the voice commands
- add art and verify cmd for emma
- add roastwilly cmd
- fix rp cmd formatting
Diffstat (limited to 'src/bot.ts')
| -rw-r--r-- | src/bot.ts | 46 |
1 files changed, 44 insertions, 2 deletions
@@ -1,24 +1,36 @@ -import config from './config.json'; +import config from './config.json'; // Import config import { CommandoClient } from 'discord.js-commando'; + //import WS from './server'; + +// Import MongoDB database models import Welcome from './models/welcome.js'; import Goodbye from './models/goodbye.js'; +import Verify from './models/Verify'; + +// Connect to database import mongoose from 'mongoose'; mongoose.connect(config['mongodburi'], { useNewUrlParser: true, useUnifiedTopology: true }) + import path from 'path'; // @ts-ignore emoji-random doesn't have types import emoji from 'emoji-random'; import { MessageEmbed } from 'discord.js'; + +// Import music functions require('./models/MusicGuild.js') +// Register client with basic information const client = new CommandoClient({ commandPrefix: 'uwu!', owner: '217348698294714370', invite: 'https://discord.gg/DVwXUwx' }); +// Make webserver public //const ws = new WS(process.env.PORT, client) +// Register more client information client.registry .registerDefaultTypes() .registerGroups([ @@ -46,6 +58,7 @@ client.registry .registerCommandsIn(path.join(__dirname, 'commands')); client.once('ready', async () => { + // Console out basic bot information //console.log(`Started bot: ${client.user.tag} (ID: ${client.user.id})\nCurrently running on ${client.guilds.cache.size} server(s).`); console.log('\x1b[0m' + 'Bot online!') console.log('\x1b[31m' + ` _ _ __ _ @@ -64,6 +77,7 @@ client.once('ready', async () => { console.log('\x1b[0m' + 'Servers: ' + '\x1b[36m' + `${client.guilds.cache.size}` + '\x1b[0m') console.log() + // Set status // i would use a set interval in the main msg body but this is better for now because during maintenance you tend to refresh refresh a lot // kinda crap if you forget to change uppity's status off of maintainence... 2020/05/05, 17:29 if ((await client.users.fetch('705537104339402815')).presence.activities[0].name == 'maintenance') { @@ -77,10 +91,12 @@ client.once('ready', async () => { } }); +// Debug stuff client.on('error', console.error); //client.on('debug', console.debug); client.on('warn', console.warn) +// Logging information client.on('guildCreate', guild => { console.log(`Joined server: ${guild.name}`) let embed = new MessageEmbed() @@ -95,7 +111,28 @@ client.on('guildDelete', guild => { client.guilds.cache.get('704032355987488791')?.channels.cache.get('706818034999754792')?.send(`Joined server: **${guild.name}**.`) }) -client.on('guildMemberAdd', member => { +client.on('guildMemberAdd', async member => { + /* if (member.guild.id.toString() == '663964105983393793') { + const captchaKey = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); + const emmaServer = 663964105983393793; + const unverRole = '729928740359897101'; + member.roles.add(unverRole); + const verify = new Verify({ + _id: mongoose.Types.ObjectId(), + username: member.user.username, + userID: member.user.id, + status: false, + key: captchaKey + }) + await verify.save() + .then(result => console.log(result)) + .catch(err => console.log(err)) + //@ts-ignore + member.send(`Please type \`uwu!verify ${captchaKey}\` to be verified.`) + // member.guild.channels.cache.get('729931444008517762')?.send(`Please send the message; \`uwu!verify ${captchaKey}\` to the server channel; \`#verification\` in order to be verified. ${emoji.random()}`); + } */ + + // Execute welcome command if present Welcome.findOne({ guildID: member.guild.id }, async (error, guild) => { if (error) { console.log(error) @@ -110,6 +147,7 @@ client.on('guildMemberAdd', member => { }) }) client.on('guildMemberRemove', member => { + // Execute goodbye command if present Goodbye.findOne({ guildID: member.guild.id }, async (error, guild) => { if (error) { console.log(error) @@ -124,8 +162,10 @@ client.on('guildMemberRemove', member => { }) }) +// Just more logging stuff basically client.on('message', async msg => { const msgContent = msg.content.toLowerCase(); + // Check if the prefix is present in a string function prefixCheck() { // shorthand ? : if else doesn't work for some reason if (msgContent.startsWith('uwu!')) @@ -145,10 +185,12 @@ client.on('message', async msg => { } } + // If a message mentions everyone, react with a random emoji if (msg.mentions.everyone) { msg.react(emoji.random()); } }); +// Register client client.login(config['secret']); //client.login(config['secret-dev']);
\ No newline at end of file |