-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Added basic functionality for /piano for Utility Bot C5 Major only
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,93 @@ | ||
const Discord = require('discord.js'); | ||
const fs = require('fs'); | ||
const bot = new Discord.Client(); | ||
|
||
const token = 'no lol'; | ||
const token = fs.readFileSync('./appdata/token.txt', 'utf-8'); | ||
bot.login(token); | ||
|
||
const prefix = '/'; | ||
|
||
let slots = []; | ||
let progress = []; //1=started 2=finished 3=abandoned | ||
var latest = 0; | ||
const allow = []; | ||
var channels = []; | ||
var intervalId = 0; | ||
var pianoMessage; | ||
var pianoConnection; | ||
var pianoChannel; | ||
|
||
bot.on('ready', () => { console.log('Bot is online'); }) | ||
//bot.on('message', msg => {if(msg.content === "HELLO"){msg.reply('HELLO!')};}) | ||
|
||
bot.on('message', message => { | ||
|
||
|
||
|
||
let args = message.content.substring(prefix.length).split(" "); | ||
if (message.content.substring(0, 1) === prefix) { | ||
if (allow.length > 0 && !allow.includes(args[0])) { console.log("Returned: " + args[0]); return; } | ||
|
||
|
||
switch (args[0]) { | ||
case 'cls': | ||
message.channel.bulkDelete(99); | ||
case 'piano': | ||
if (!message.member.voice.channel) { | ||
message.reply(`join a voice channel first!`); | ||
return; | ||
} | ||
message.reply(`here's your piano:\nCareful, I may be loud!`).then(msg => { | ||
pianoMessage = msg; | ||
msg.react('🇦'); | ||
msg.react('🇧'); | ||
msg.react('🇨'); | ||
msg.react('🇩'); | ||
msg.react('🇪'); | ||
msg.react('🇫'); | ||
msg.react('🇬'); | ||
}); | ||
message.member.voice.channel.join().then(connection => { | ||
pianoConnection = connection; | ||
pianoChannel = message.member.voice.channel; | ||
}).catch(console.error('Connection failed to attach')); | ||
break; | ||
case 'test': | ||
message.reply(message.member.time); | ||
|
||
case 'unpiano': | ||
if (!pianoChannel) { | ||
pianoChannel.leave(); | ||
} | ||
pianoChannel = null; | ||
pianoConnection = null; | ||
pianoMessage = null; | ||
message.reply('unpianoed'); | ||
break; | ||
|
||
} | ||
} | ||
}) | ||
}) | ||
|
||
bot.on('messageReactionAdd', (reaction, user) => { | ||
if (user.id == bot.user.id) { return; } | ||
if (!pianoMessage) { return; } | ||
if (reaction.message.id != pianoMessage.id) { return; } | ||
var note; | ||
switch (reaction.emoji.name) { | ||
case '🇦': | ||
note = 'A'; | ||
break; | ||
case '🇧': | ||
note = 'B'; | ||
break; | ||
case '🇨': | ||
note = 'C'; | ||
break; | ||
case '🇩': | ||
note = 'D'; | ||
break; | ||
case '🇪': | ||
note = 'E'; | ||
break; | ||
case '🇫': | ||
note = 'F'; | ||
break; | ||
case '🇬': | ||
note = 'G'; | ||
break; | ||
default: | ||
reaction.users.remove(user.id).catch(console.error('Failed to remove reaction')); | ||
return; | ||
} | ||
reaction.users.remove(user.id).catch(console.error('Failed to remove reaction')); | ||
console.log(`${user.username} played ${note}`); | ||
|
||
//Play: | ||
const dispatcher = pianoConnection.play(`./appdata/notes/${note}.wav`); | ||
// | ||
return; | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.