mirror of
https://github.com/Alee14/DLAP.git
synced 2025-01-22 19:02:57 -05:00
Inital commit
This commit is contained in:
commit
9a1ac86aed
3 changed files with 58 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
token.json
|
||||||
|
node_modules
|
||||||
|
yarn.lock
|
46
bot.js
Normal file
46
bot.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
const Discord = require('discord.js');
|
||||||
|
const client = new Discord.Client();
|
||||||
|
const config = require('./token.json');
|
||||||
|
let prefix = "!"
|
||||||
|
|
||||||
|
client.on('ready', () => {
|
||||||
|
console.log(`Logged in as ${client.user.tag}!`);
|
||||||
|
console.log('Prefix:', prefix)
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('message', async msg => {
|
||||||
|
if (!['242775871059001344'].includes(msg.author.id)) return;
|
||||||
|
if (!msg.guild) return;
|
||||||
|
if (msg.author.bot) return;
|
||||||
|
if (!msg.content.startsWith(prefix)) return;
|
||||||
|
|
||||||
|
let command = msg.content.split(" ")[0];
|
||||||
|
command = command.slice(prefix.length);
|
||||||
|
|
||||||
|
if (command == 'ping') {
|
||||||
|
msg.reply('Pong!');
|
||||||
|
}
|
||||||
|
if (command == 'poweroff') {
|
||||||
|
console.log("Powering off...");
|
||||||
|
client.destroy();
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
if (command === 'join') {
|
||||||
|
// Only try to join the sender's voice channel if they are in one themselves
|
||||||
|
if (msg.member.voice.channel) {
|
||||||
|
const connection = await msg.member.voice.channel.join();
|
||||||
|
} else {
|
||||||
|
msg.reply('You need to join a voice channel first!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (command === 'leave') {
|
||||||
|
// Only try to join the sender's voice channel if they are in one themselves
|
||||||
|
if (msg.member.voice.channel) {
|
||||||
|
const connection = await msg.member.voice.channel.leave();
|
||||||
|
} else {
|
||||||
|
msg.reply('You need to join a voice channel first!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
client.login(config.token);
|
9
package.json
Normal file
9
package.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"name": "Project-Jul-2020-Discord-Bot",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"discord.js": "^12.2.0"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue