Transitioned all Misc, audio, Selmer Specific, admin, anime/manga, and inventory commands to Slash Command format. The RSS and reactionrole commands are still broken and all game commands are still in message format due to compications

This commit is contained in:
ION606
2022-09-27 16:45:50 -04:00
parent a190a250a6
commit e1002d748d
45 changed files with 1951 additions and 1058 deletions
+3 -2
View File
@@ -1,4 +1,4 @@
const { Formatters, MessageEmbed } = require('discord.js');
const { Formatters, MessageEmbed, Constants } = require('discord.js');
const CoinGecko = require('coingecko-api');
const CoinGeckoClient = new CoinGecko();
@@ -72,5 +72,6 @@ module.exports = {
console.error(err);
return message.reply("Uh Oh! There's been an error!");
}
}
},
options: [{name: 'qeury', description: 'Name or List', type: Constants.ApplicationCommandOptionTypes.STRING, required: true}]
}
+4 -3
View File
@@ -1,7 +1,8 @@
module.exports = {
name: "test",
description: "HI SELMER",
execute(message, args, Discord, Client, bot) {
message.channel.send("HI SELMER!!!");
}
execute(interaction, Discord, Client, bot) {
interaction.reply("HI SELMER!!!");
},
options: []
}
+17 -10
View File
@@ -1,28 +1,34 @@
const { modHelp } = require('../admin/moderation.js');
const { Constants } = require('discord.js');
//CHANGE THIS TO FORMS?
module.exports ={
name: "help",
description: "Gets help for all of Selmer Bot's commands",
execute(message, args, Discord, Client, bot) {
execute(interaction, Discord, Client, bot) {
const groups = new Map([['SBspec', ['arrow', 'extracredit', 'profile', 'quotes', 'code']], ['adminCommands', [ 'setup', 'lock', 'unlock', 'serverlock' ]]]);
var spec = "";
if (interaction.options.data[0]) {
spec = interaction.options.data[0].value;
}
if (args[0] == 'econ') {
if (spec == 'econ') {
let temp = "***Selmer Bot Commands (Econ):***\n";
temp += bot.commands.get('econ').econHelp();
temp += `\n\n(remember to use _'${bot.prefix}'_ before the command!)`;
return message.channel.send(temp);
return interaction.reply({ content: temp, ephemeral: true });
}
else if (args[0] == 'game') {
else if (spec == 'game') {
let temp = "***Selmer Bot Commands (Games):***\n";
temp += bot.commands.get('game').allGames.join(", ");
temp += `\n\n(remember to use _'${bot.prefix}game'_ before the command!)`;
return message.channel.send(temp);
temp += `\n\n_Note: due to how complicated this feature is, it will not be migrated to slash commands for now_`;
return interaction.reply({ content: temp, ephemeral: true });
}
else if (args[0] == 'admin') {
else if (spec == 'admin') {
let temp = `__**Selmer Bot Admin Commands**__\n`
Array.from(groups.get('adminCommands')).forEach(commName => {
let comm = bot.commands.get(commName);
@@ -36,7 +42,7 @@ module.exports ={
temp += '\n_setup_ - ***SERVER OWNER ONLY*** - use _!setup help_\n';
temp += `\n\n(remember to use _'${bot.prefix}'_ before the command!)`;
return message.channel.send(temp);
return interaction.reply({ content: temp, ephemeral: true });
}
let temp = "***Selmer Bot Commands:***\n";
@@ -73,6 +79,7 @@ module.exports ={
temp += `\n_(remember to use '${bot.prefix}' before the command!)_`;
message.channel.send(temp);
}
interaction.reply({ content: temp, ephemeral: true });
},
options: [{name: 'command', description: 'econ, game, or admin', type: Constants.ApplicationCommandOptionTypes.STRING, required: false, choices: [ { name: 'econ', value: 'econ' }, { name: 'game', value: 'game' }, {name: 'admin', value: 'admin'} ]}]
}
+24 -18
View File
@@ -1,26 +1,32 @@
const { Constants } = require('discord.js');
module.exports ={
name: 'kareoke',
description: 'Sing your least-favorite song with your favorite person, me!',
execute(message, args, Discord, Client, bot) {
execute(interaction, Discord, Client, bot) {
const arg = interaction.options.data[0].value;
if (arg == "help") { return interaction.reply({content: "Please pick out a song at https://www.karaoke-lyrics.net/\nThe command should look like\n/kareoke [link_here]"}); }
const axios = require('axios');
const cheerio = require('cheerio')
const url = args[0];
if (args[0] == undefined) {
message.channel.send("Please pick out a song at https://www.karaoke-lyrics.net/\nThe command should look like\n/kareoke [link_here]");
} else {
axios(url)
.then(response => {
const html = response.data;
const $ = cheerio.load(html);
lyrics = $('.para_row').text();
breakbar = "---------------------------------------------";
message.channel.send(breakbar + "\n" + lyrics + "\n" + breakbar);
//console.log(lyrics);
})
.catch(console.error);
}
}
const url = interaction.options.data[0].value;
axios(url)
.then(response => {
const html = response.data;
const $ = cheerio.load(html);
lyrics = $('.para_row').text();
breakbar = "---------------------------------------------";
message.channel.send(breakbar + "\n" + lyrics + "\n" + breakbar);
//console.log(lyrics);
})
.catch((err) => {
console.log(err);
interaction.reply("Please provide a valid url from https://www.karaoke-lyrics.net/");
});
},
options: [{name: 'url', description: 'the url of the song or "help"', type: Constants.ApplicationCommandOptionTypes.STRING, required: true}]
}
//TEST: https://www.karaoketexty.cz/texty-pisni/zoegirl/plain-170199
+4 -4
View File
@@ -1,15 +1,15 @@
module.exports = {
name: "links",
description: "A helpful list of links to all of Selmer's wonderful websites",
execute(message, args, Discord, Client, bot) {
execute(interaction, Discord, Client, bot) {
const newEmbed = new Discord.MessageEmbed()
.setColor('#002eff')
.setTitle("Selmer's Links")
.addFields(
{name: 'HyperGrader', value: "https://rpi.logicamodernapproach.com/"},
{name: 'Personal Website', value: "http://www.logicamodernapproach.com/rpi/intlogs22.bringsjord/#sec-3"}
{name: 'Personal Website', value: "http://www.logicamodernapproach.com/"}
);
message.channel.send({ embeds: [newEmbed] });
}
interaction.reply({ embeds: [newEmbed] });
}, options: []
}
+6 -5
View File
@@ -5,7 +5,8 @@ const { randomHexColor } = require('../admin/colorgen.js');
module.exports = {
name: 'meme',
description: 'Selmer Bot will post a random meme from reddit',
async execute(message, args, Discord, Client, bot) {
async execute(interaction, Discord, Client, bot) {
interaction.deferReply();
memes.random().then(meme => {
const newEmbed = new Discord.MessageEmbed()
@@ -15,7 +16,7 @@ module.exports = {
.setDescription(`category: ${meme.category}`)
.setImage(meme.image);
message.channel.send({ embeds: [newEmbed] });
interaction.editReply({ embeds: [newEmbed] });
}).catch(async err => {
console.log(err);
//Try a different way
@@ -23,7 +24,7 @@ module.exports = {
const response = await fetch('https://some-random-api.ml/meme');
const data = await response.json().catch(err => {
console.log(err);
return message.reply("_Uh oh, something's gone wrong!_");
return interaction.reply("_Uh oh, something's gone wrong!_");
});
const newEmbed = new Discord.MessageEmbed()
@@ -33,7 +34,7 @@ module.exports = {
.setDescription(`category: ${data.category}`)
.setImage(data.image);
message.channel.send({ embeds: [newEmbed] });
interaction.editReply({ embeds: [newEmbed] });
});
}
}, options: []
}
+10 -8
View File
@@ -1,4 +1,5 @@
// https://ponly.com/200-pick-up-lines/
const { Constants } = require('discord.js');
const cheesy = [
'If I said you had a good body would you hold it against me?',
@@ -280,32 +281,33 @@ const anime = [
module.exports = {
name: 'pickupline',
description: 'Get a pickup line from our selection of 200 lines!',
execute(message, args, Discord, Client, bot) {
execute(interaction, Discord, Client, bot) {
const nameList = new Map([['cheesy', cheesy], ['funny', funny], ['smooth', smooth], ['best', best], ['anime', anime]]);
const type = interaction.options.data[0].value;
if (args[0] == 'sources') {
if (type == 'sources') {
message.reply("The normal lines are from https://ponly.com/200-pick-up-lines/\nThe anime lines are from https://thoughtcatalog.com/january-nelson/2021/06/anime-pick-up-lines/")
.then((msg) => { msg.suppressEmbeds(true); })
return;
}
if (args.length < 1 || (!nameList.get(args[0]) && args[0] != 'random')) { return message.reply("Please use the following format !pickupline <'cheesy', 'funny', 'smooth', 'best', 'anime', 'random', 'sources'>"); }
var key;
if (args[0] == 'random') {
if (type == 'random') {
let keyInd = Math.floor(Math.random() * nameList.size);
key = Array.from(nameList.keys())[keyInd];
} else {
key = args[0];
key = type;
}
const arr = nameList.get(key);
keyInd = Math.floor(Math.random() * arr.length);
try {
message.reply(arr[keyInd]);
interaction.reply(arr[keyInd]);
} catch {
message.channel.send(arr[keyInd]);
interaction.channel.send(arr[keyInd]);
}
}
},
options: [{name: 'type', description: 'Pick the genre of line or take a chance with random!', type: Constants.ApplicationCommandOptionTypes.STRING, required: true, choices: [{name: "cheesy", value: "cheesy"}, {name: "funny", value: "funny"}, {name: "smooth", value: "smooth"}, {name: "best", value: "best"}, {name: "anime", value: "anime"}, {name: "random", value: "random"}, {name: "sources", value: "sources"} ] }]
}
-459
View File
@@ -1,459 +0,0 @@
const pathToFfmpeg = require('ffmpeg-static');
// const { joinVoiceChannel, createAudioResource } = require('@discordjs/voice');
const { VoiceConnectionStatus, AudioPlayerStatus, createAudioPlayer, StreamType, joinVoiceChannel, createAudioResource, getVoiceConnection } = require('@discordjs/voice');
const { MessageActionRow, MessageButton, MessageEmbed, MessageSelectMenu, Message } = require('discord.js');
const play = require('play-dl');
// Note: Unsure of what this does , but may be related to the play-dl lib (my notes are inconsistent)
// play.authorization();
function playStopEmbed(bot, interaction, yt_info, stopped, message = null) {
if (stopped) {
var em = interaction.message.embeds[0];
rows = [];
em.description = new String;
em.description = 'IS NOW STOPPED';
interaction.update({embeds: [em], components: rows});
} else {
const author = {
name: "Selmer Bot",
url: "",
iconURL: bot.user.displayAvatarURL()
}
const newEmbed = new MessageEmbed()
.setColor('#0F00F0')
.setTitle(`${yt_info.video_details.title}`)
.setAuthor(author)
.setDescription('IS NOW PLAYING')
.setURL(yt_info.video_details.url)
.setThumbnail(yt_info.video_details.thumbnails[0].url);
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('PAUSE')
.setLabel('⏸️')
.setStyle('SECONDARY'),
new MessageButton()
.setCustomId('STOP')
.setLabel('⏹️')
.setStyle('SECONDARY'),
new MessageButton()
.setCustomId('SKIP')
.setLabel('⏭️')
.setStyle('SECONDARY')
);
if (message) {
const m = message.reply({ embeds: [newEmbed], components: [row] });
m.then((msg) => {
const data = bot.audioData.get(message.guild.id);
data[2] = msg.id;
bot.audioData.set(message.guild.id, data);
})
} else {
interaction.update({embeds: [newEmbed], components: [row]});
}
}
}
function pause_start_stop(interaction, bot, message = null, command = null) {
try {
var player, em;
if (interaction) {
player = bot.audioData.get(interaction.guildId)[0];
command = interaction.customId.toLowerCase();
em = interaction.message.embeds[0];
} else {
player = bot.audioData.get(message.guild.id)[0];
em = message.embeds[0];
}
var rows = [new MessageActionRow()];
if (command == "pause") {
rows[0].addComponents(
new MessageButton()
.setCustomId('RESUME')
.setLabel('▶️')
.setStyle('SECONDARY'),
new MessageButton()
.setCustomId('STOP')
.setLabel('⏹️')
.setStyle('SECONDARY'),
new MessageButton()
.setCustomId('SKIP')
.setLabel('⏭️')
.setStyle('SECONDARY')
);
em.description = 'IS NOW PAUSED';
player.pause();
} else if (command == "resume") {
rows[0].addComponents(
new MessageButton()
.setCustomId('PAUSE')
.setLabel('⏸️')
.setStyle('SECONDARY'),
new MessageButton()
.setCustomId('STOP')
.setLabel('⏹️')
.setStyle('SECONDARY'),
new MessageButton()
.setCustomId('SKIP')
.setLabel('⏭️')
.setStyle('SECONDARY')
);
em.description = 'IS NOW PLAYING';
player.unpause();
} else if (command == "stop") {
playStopEmbed(bot, interaction, null, true);
const connection = getVoiceConnection(interaction.guild.id);
player.stop();
//Remove everything from queue
bot.audioData.delete(interaction.guildId);
if (connection) { connection.destroy(); }
return;
}
if (interaction) { interaction.update({embeds: [em], components: rows}); }
else {
const data = bot.audioData.get(message.guild.id);
// var msg = message.channel.messages.cache.get(data[2]);
const newEmbed = message.embeds[0];
newEmbed.description = "Has been deferred";
message.edit({ embeds: [ newEmbed ], components: []});
const m = message.reply({embeds: [em], components: rows});
m.then((msg) => {
const data = bot.audioData.get(message.guild.id);
data[2] = msg.id;
bot.audioData.set(message.guild.id, data);
})
}
} catch (e) {
console.log(e);
rows = [];
em.description = new String('IS NOW STOPPED');
interaction.update({embeds: [em], components: rows});
}
}
function playNext(interaction, bot, message = null) {
// https://discordjs.guide/voice/audio-player.html#taking-action-within-the-error-handler
//Setup data[1] = {info: yt_info, resource: resource}
var guildId;
if (message != null) { guildId = message.guild.id; }
else { guildId = interaction.guildId; }
let data = bot.audioData.get(guildId);
const player = data[0];
//Check if the queue is empty
if (data[1].length <= 0) {
player.stop();
bot.audioData.delete(guildId);
if (message) { return true; }
else { return playStopEmbed(bot, interaction, null, true); }
}
const resource = data[1][0].resource;
const yt_info = data[1][0].yt_info;
player.stop();
//Play the thing
player.play(resource);
//remove the song from queue
delete data[1][0];
data[1] = data[1].filter(n => n);
bot.audioData.set(guildId, data);
//Add the embed
var msg = message;
if (!message) {
msg = interaction.message;
interaction.update({ embeds: [ new MessageEmbed(interaction.message.embeds[0]).setDescription("IS NOW STOPPED") ], components: []});
}
playStopEmbed(bot, interaction, yt_info, false, msg);
return false;
}
function fromMessage(bot, command, msg) {
//Setup data[1] = {info: yt_info, resource: resource}
const guildId = msg.guild.id;
let data = bot.audioData.get(guildId);
if (!data) { return msg.reply("No music is currently playing!"); }
const player = data[0];
const message = msg.channel.messages.cache.get(data[2]);
// console.log(message);
var em;
if (message.embeds) { em = message.embeds[0]; }
var rows;
if (command == 'stop') {
em = message.embeds[0];
rows = [];
em.description = new String;
em.description = 'IS NOW STOPPED';
player.stop();
const connection = getVoiceConnection(guildId);
if (connection) { connection.destroy(); }
bot.audioData.delete(guildId);
msg.reply("Audio stopped!");
} else if (command == 'skip') {
if (playNext(null, bot, message)) {
rows = [];
em = message.embeds[0];
em.description = new String;
em.description = 'IS NOW STOPPED';
msg.reply("Audio stopped!");
}
} else if (command == 'pause' || command == 'resume') {
pause_start_stop(null, bot, message, command);
}
message.edit({embeds: [em], components: rows});
}
function showQueue(bot, message, interaction = null, page = 0) {
const guild = message.guild.id;
const data = bot.audioData.get(guild);
if (!data) { return message.reply("The audio queue is empty!"); }
const rawQueue = data[1];
if (!rawQueue || rawQueue.length <= 0) { return message.reply("The audio queue is empty!"); }
const songList = [];
var fiveSongs = '';
let i = 0;
rawQueue.forEach(function (rawSong) {
const songDetails = rawSong.yt_info.video_details;
fiveSongs += `${i + 1}. ${songDetails.title}\n`;
i++;
//Split the songs into pages of 10
if (i % 10 == 0) { songList.push(fiveSongs); fiveSongs = ''; }
});
if (page >= songList.length) { page = songList.length - 1 }
if (page < 0) { page = 0; } //LEAVE AS TWO IF's AS THE LENGTH MIGHT BE 0
if (songList.length == 0) { songList.push(fiveSongs); }
//Create the embed
const author = {
name: "Selmer Bot",
url: "",
iconURL: bot.user.displayAvatarURL()
}
const newEmbed = new MessageEmbed()
.setTitle("SONG QUEUE")
.setAuthor(author)
.setDescription(songList[page])
.setFooter({ text: `Page ${page + 1}` })
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`audioQueue|${page - 1}`)
.setLabel('⬅️')
.setStyle('SECONDARY'),
new MessageButton()
.setCustomId(`audioQueue|${page + 1}`)
.setLabel('➡️')
.setStyle('SECONDARY'),
)
if (interaction) {
interaction.update({embeds: [newEmbed], components: [row]});
} else {
message.reply({ embeds: [newEmbed], components: [row] });
}
}
function removeFromQueue(bot, message, posStr) {
const guildId = message.guild.id;
let data = bot.audioData.get(guildId);
if (!data) { return message.reply("The audio queue is empty!"); }
const rawQueue = data[1];
if (!rawQueue || rawQueue.length <= 0) { return message.reply("The audio queue is empty!"); }
else if (isNaN(posStr) || Number(posStr) > rawQueue.length) { return message.reply("Please specify a number within queue bounds!"); }
const pos = Number(posStr) - 1;
const details = rawQueue[pos].yt_info.video_details;
delete data[1][pos];
data[1] = data[1].filter(n => n);
bot.audioData.set(guildId, data);
const newEmbed = new MessageEmbed()
.setColor('#0F00F0')
.setTitle(`${details.title}`)
.setAuthor({ name: "Selmer Bot", url: "", iconURL: bot.user.displayAvatarURL() })
.setDescription( `has been removed from position ${pos + 1} in queue!`)
.setThumbnail(details.thumbnails[0].url);
message.reply({ embeds: [newEmbed] });
}
function shuffleQueue(bot, message) {
const guildId = message.guild.id;
let data = bot.audioData.get(guildId);
if (!data) { return message.reply("The audio queue is empty!"); }
let rawQueue = data[1];
if (!rawQueue || rawQueue.length <= 0) { return message.reply("The audio queue is empty!"); }
//Shuffle the queue
rawQueue = rawQueue.sort(() => Math.random()-0.5);
data[1] = rawQueue;
bot.audioData.set(guildId, data);
message.reply("The queue has been shuffled!\nThe new queue is:");
showQueue(bot, message);
}
module.exports = {
name: "audio",
description: 'Play a song from YouTube, add free!',
async execute(message, args, Discord, Client, bot, interaction = null) {
const commandList = ['stop', 'skip', 'pause', 'resume'];
if (args.length < 1) {
message.reply("Please use the following format _!audio [song name or URL]_ **or** _!audio queue_");
return;
} else if (args[0] == 'queue') {
return showQueue(bot, message);
} else if (commandList.indexOf(args[0]) != -1) {
return fromMessage(bot, args[0], message);
} else if (args[0] == 'remove') {
if (args.length < 2) { return message.reply("Please specify a position in queue!"); }
return removeFromQueue(bot, message, args[1]);
} else if (args[0] == 'shuffle') {
return shuffleQueue(bot, message);
}
/*
Re-introduce once the issue with ydtl-core is resolved (see
https://github.com/porridgewithraisins/jam-bot#known-bugs)
const stream = await ytdl(url, { filter: 'audioonly' });
*/
if (!message.member.voice.channel) {
message.reply("Please join a voice channel before you try this!");
return;
}
const channel = bot.channels.cache.get(message.member.voice.channel.id);
// console.log(message.member.voice.channel.id);
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
connection.on(VoiceConnectionStatus.Ready, () => {
// console.log('Connected to the voice channel!');
});
let stream;
let yt_info;
if (args[0].startsWith("https://")) {
if (!args[0].startsWith("https://www.youtube.com/") &&
!args[0].startsWith("https://music.youtube.com/")) {
message.reply("This is not a valid YouTube URL");
return;
}
yt_info = await play.video_info(args[0]);
// let stream = await play.stream_from_info(yt_info)
stream = await play.stream(args[0]);
// console.log("Playing from a URL!");
} else {
yt_info = await play.search(args.join(' '), {
limit: 1
});
stream = await play.stream(yt_info[0].url);
yt_info = await play.video_info(yt_info[0].url);
}
let resource = createAudioResource(stream.stream, {
inputType: stream.type
})
// let audio = "em.mp3";
// let resource = createAudioResource(join(__dirname, audio));
const data = bot.audioData.get(channel.guild.id);
if (data && data[1]) {
//[player, [queue Array]]
data[1].push({yt_info: yt_info, resource: resource});
bot.audioData.set(message.guild.id, data);
message.reply(`_"${yt_info.video_details.title}" added to queue!_`);
} else {
const player = createAudioPlayer();
connection.subscribe(player);
bot.audioData.set(message.guild.id, [player, new Array(), null]);
player.play(resource);
player.on(AudioPlayerStatus.Playing, () => {
//Check maybe?
});
playStopEmbed(bot, interaction, yt_info, false, message);
}
}, pause_start_stop, playNext, showQueue
}
+33 -16
View File
@@ -1,13 +1,12 @@
const { MessageEmbed } = require('discord.js');
const { MessageEmbed, Constants } = require('discord.js');
//!poll <name> <option 1, option 2> [option 3...option 10]
module.exports = {
name: "poll",
description: "Create a cool poll embed (with time up to 1 hour!)",
async execute(message, args, Discord, Client, bot) {
if (args.length < 3) { return message.reply("Please provide a poll name, time (like 1:25 or 0 for not timed) and 1 - 10 options!"); }
if (args.length > 12) { return message.reply("Please specify less than 10 options!"); }
async execute(interaction, Discord, Client, bot) {
const args = interaction.options.data;
const timeList = [ '1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '🔟' ];
const author = {
@@ -15,32 +14,36 @@ module.exports = {
url: "",
iconURL: bot.user.displayAvatarURL()
}
const name = args.filter((arg) => { return (arg.name == 'question'); })[0].value;
var time = 0;
const time = interaction.options.data.filter((arg) => { return (arg.name == 'time'); })[0].value;
var temp;
var isTimed = !Number.isNaN(Number(args[1].split(":")[0]));
// var isTimed = !Number.isNaN(Number(args[1].split(":")[0]));
if (!isTimed) {
temp = `This poll was created by ${message.author} and has no time limit!\n`;
if (time != 0) {
temp = `This poll was created by ${interaction.user} and has no time limit!\n`;
} else {
time += (Number(args[1].split(':')[0]) * 60) + Number(args[1].split(':')[1]);
temp = `This poll was created by ${message.author} and ends <t:${Math.floor((new Date()).getTime()/1000) + time}:R>!\n`;
time += time * 60; // (Number(args[1].split(':')[0]) * 60) + Number(args[1].split(':')[1]);
temp = `This poll was created by ${interaction.user} and ends <t:${Math.floor((new Date()).getTime()/1000) + time}:R>!\n`;
}
//args[0] is the poll name
for(let i = 2; i < args.length; i ++) {
for(let i = 0; i < args.length; i ++) {
if (args[i].name.indexOf('option') == -1) { continue; }
// complist.push({ name: `${timeList[i - 1]}: ${args[i]}`, value: "" });
temp += `\n${timeList[i - 2]}: ${args[i]}\n`;
temp += `\n${timeList[i - 2]}: ${args[i].value}\n`;
}
const embd = new MessageEmbed()
.setTimestamp()
.setTitle(`${args[0]}`)
.setTitle(`${name}`)
.setDescription(temp)
.setAuthor(author)
message.channel.send({ embeds: [embd] }).then((msg) => {
const m = interaction.channel.send({ embeds: [embd] });
m.then((msg) => {
interaction.reply("Poll Posted!");
for(let i = 0; i < args.length - 2; i ++) {
msg.react(timeList[i]);
}
@@ -85,5 +88,19 @@ module.exports = {
msg.reply(temp);
});
});
}
},
options: [
{name: 'question', description: 'The poll question...', type: Constants.ApplicationCommandOptionTypes.STRING, required: true},
{name: 'time', description: 'the time the poll is open for in minutes (for no limit input 0)', type: Constants.ApplicationCommandOptionTypes.INTEGER, required: true},
{name: 'option1', description: 'A poll option', type: Constants.ApplicationCommandOptionTypes.STRING, required: true},
{name: 'option2', description: 'A poll option', type: Constants.ApplicationCommandOptionTypes.STRING, required: false},
{name: 'option3', description: 'A poll option', type: Constants.ApplicationCommandOptionTypes.STRING, required: false},
{name: 'option4', description: 'A poll option', type: Constants.ApplicationCommandOptionTypes.STRING, required: false},
{name: 'option5', description: 'A poll option', type: Constants.ApplicationCommandOptionTypes.STRING, required: false},
{name: 'option6', description: 'A poll option', type: Constants.ApplicationCommandOptionTypes.STRING, required: false},
{name: 'option7', description: 'A poll option', type: Constants.ApplicationCommandOptionTypes.STRING, required: false},
{name: 'option8', description: 'A poll option', type: Constants.ApplicationCommandOptionTypes.STRING, required: false},
{name: 'option9', description: 'A poll option', type: Constants.ApplicationCommandOptionTypes.STRING, required: false},
{name: 'option10', description: 'A poll option', type: Constants.ApplicationCommandOptionTypes.STRING, required: false},
]
}
+25 -20
View File
@@ -1,3 +1,5 @@
//NOTE: THIS FUNCTION REQUIRES REPLIES, AND I CAN'T FIGURE OUT HOW TO LINK THEM TO SLASH COMMANDS
module.exports = {
name: 'react',
description: "Reacts with a phrase or single emoji",
@@ -8,31 +10,34 @@ module.exports = {
if (message.reference) {
msg = await message.channel.messages.fetch(message.reference.messageId);
} else { msg = message; }
//Get rid of any custom emojis
console.log("IMPLEMENT THIS");
let emoji = [...new Set(args[0])];
if (emoji.length > 15 /*|| message.IndexOf(":") != -1*/) { return message.reply("Please enter less than 15 emojis"); }
let notused = new Array(15);
let counter = 0;
try {
let emoji = [...new Set(args[0])];
if (emoji.length > 15 /*|| message.IndexOf(":") != -1*/) { return message.reply("Please enter less than 15 emojis"); }
let notused = new Array(15);
let counter = 0;
for (let i = 0; i < emoji.length; i ++) {
try {
await msg.react(emoji[i]);
} catch(err) {
//The emoji wasn't a valid one
notused[counter] = emoji[i];
counter ++;
for (let i = 0; i < emoji.length; i ++) {
try {
await msg.react(emoji[i]);
} catch(err) {
//The emoji wasn't a valid one
notused[counter] = emoji[i];
counter ++;
}
}
}
if (notused.length > 0) {
notused = notused.filter(element => element !== undefined);
if (notused.length > 1) {
message.reply("These are not valid reaction emoji(s): " + notused.toString());
} else {
message.reply(notused.toString() + " is not a valid reaction emoji");
if (notused.length > 0) {
notused = notused.filter(element => element !== undefined);
if (notused.length > 1) {
message.reply("These are not valid reaction emoji(s): " + notused.toString());
} else {
message.reply(notused.toString() + " is not a valid reaction emoji");
}
}
} catch (err) {
console.log(err);
return message.reply("Uh oh, there's been an error");
}
}
}
+30 -24
View File
@@ -1,35 +1,41 @@
const hastebin = require("hastebin-gen");
const { addComplaintButton } = require('../dev only/submitcomplaint');
const { Constants } = require('discord.js');
module.exports ={
name: "scrape",
description: ".....",
async execute(message, args, Discord, Client, bot) {
description: "Scrapes a website, then puts the result into a hastebin",
async execute(interaction, Discord, Client, bot) {
const axios = require('axios');
const cheerio = require('cheerio');
const url = args[0];
axios(url)
.then(async response => {
const html = response.data;
const $ = cheerio.load(html);
//lyrics = $('.para_row').text();
// const cheerio = require('cheerio');
const url = interaction.options.data[0].value;
axios(url)
.then(async response => {
const html = response.data;
// const $ = cheerio.load(html);
//lyrics = $('.para_row').text();
const haste = await hastebin(html, { extension: "txt" });
message.channel.send(haste);
// console.log(lyrics);
})
.catch(function(err) {
if (err.message.indexOf('The "url" argument must be of type string') != -1) {
message.reply("The URL should be a string!");
} else if (err.code == 'ERR_BAD_REQUEST') {
message.reply("404 link not valid!")
} else {
message.reply("Oops! There's been an error, click the ✅ to report this!");
addComplaintButton(bot, message);
console.log(err);
}
const haste = await hastebin(html, { extension: "txt" });
interaction.reply(haste);
// console.log(lyrics);
})
.catch(function(err) {
if (err.message.indexOf('The "url" argument must be of type string') != -1) {
interaction.reply("The URL should be a string!");
} else if (err.code == 'ERR_BAD_REQUEST') {
interaction.reply("404 link not valid!")
} else {
const m = interaction.reply("Oops! There's been an error, click the ✅ to report this!");
m.then((msg) => {
addComplaintButton(bot, msg);
});
}
console.log(err);
}
});
},
options: [{name: 'url', description: 'The website URL', type: Constants.ApplicationCommandOptionTypes.STRING, required: true }]
}
//TEST: https://www.karaoketexty.cz/texty-pisni/zoegirl/plain-170199
+29 -28
View File
@@ -1,4 +1,4 @@
const { Modal, TextInputComponent, MessageActionRow, MessageButton, MessageEmbed, Interaction } = require('discord.js');
const { Constants, MessageEmbed, Interaction } = require('discord.js');
const dateFns = require('date-fns');
const { formatToTimeZone } = require('date-fns-timezone');
@@ -13,7 +13,7 @@ const alpaca = new Alpaca({
});
//This is the same as making the following request: https://data.alpaca.markets/v2/stocks/snapshots?symbols={stock_symbols_here}
async function getStockData(bot, message, args, stock) {
async function getStockData(bot, interaction, stock, type, after) {
try {
const snapshotPromise = alpaca.getSnapshot(stock);
@@ -22,7 +22,7 @@ async function getStockData(bot, message, args, stock) {
.setAuthor({ name: "Selmer Bot", url: "", iconURL: bot.user.displayAvatarURL() })
.setFooter({ text: 'Selmer Bot uses Alpaca for stock information'})
if (args[1] == 'trade') {
if (type) {
const lt = snapshot.LatestTrade;
embd.setTitle(`${stock} Latest Trade`)
.setTimestamp(lt.Timestamp)
@@ -33,9 +33,9 @@ async function getStockData(bot, message, args, stock) {
//This will always be IEX, as it is the only exchange the free version offers
{name: 'Exchange', value: `IEX (${lt.Exchange})`},
)
} else if (args[1] == 'quote') {
if (args[2] == 'after') {
return message.reply("Due to the markets not being open, there is no quote data available!");
} else if (type) {
if (after) {
return interaction.reply("Due to the markets not being open, there is no quote data available!");
}
const lq = snapshot.LatestQuote;
embd.setTitle(`${stock} Latest Quote`)
@@ -49,7 +49,7 @@ async function getStockData(bot, message, args, stock) {
//This will always be IEX, as it is the only exchange the free version offers
{name: 'Exchange', value: `IEX (${lq.Exchange})`},
)
} else if (args[1] == 'bars') {
} else if (type) {
const mb = snapshot.MinuteBar;
const db = snapshot.DailyBar;
const pdb = snapshot.PrevDailyBar;
@@ -61,23 +61,22 @@ async function getStockData(bot, message, args, stock) {
{name: 'Day Bar (Yesterday)', value: `Open Price: ${pdb.OpenPrice},\nClose Price: ${pdb.ClosePrice},\nHigh Price: ${pdb.HighPrice},\nLow Price: ${pdb.LowPrice},\nVolume: ${pdb.Volume},\nCount: ${pdb.TradeCount},\nVWAP: ${pdb.VWAP}`},
)
} else {
return message.reply("The command format is: _!stocks <stock_name, 'hours'> <trade, quote, bars> [after]_");
return interaction.reply("The command format is: _/stocks <stock_name, 'hours'> <trade, quote, bars> [after]_");
}
message.reply({embeds: [embd]});
interaction.reply({embeds: [embd]});
})
} catch(err) {
console.error(err);
message.reply("Uh Oh, there's been an error!");
interaction.reply("Uh Oh, there's been an error!");
}
}
function getData(bot, message, args) {
var stock;
if (args.length < 1) {
return message.reply("Please specify a stock (ex: AAPL, GOOG, etc)")
} else { stock = args[0];}
function getData(bot, interaction) {
const args = interaction.options.data;
const stock = args.filter((arg) => { return (arg.name == 'name')})[0].value;
const type = args.filter((arg) => { return (arg.name == 'type')})[0].value;
const after = (args.length > 2 && args.filter((arg) => { return (arg.name == 'after')})[0].value);
const format = `yyyy-MM-dd HH:mm:ss`;
const date = dateFns.format(new Date(), format);
@@ -90,17 +89,17 @@ function getData(bot, message, args) {
end: date
}).then((calendars) => {
let temp;
if (clock.is_open || args[2] == 'after') {
if (args[0] == 'hours') {
if (clock.is_open || after) {
if (stock == 'hours') {
temp = `The markets opened at ${calendars[0].open} and will close at ${calendars[0].close} on ${date}.`;
return message.reply(temp);
return interaction.reply(temp);
}
getStockData(bot, message, args, stock);
getStockData(bot, interaction, stock, type, after);
} else {
// `The market is currently ${clock.is_open ? 'open.' : 'closed.'}`
//May be innacurate?
temp = `_The markets closed at \`${calendars[0].close}\` and will open again at \`${calendars[0].open}\` on \`${dateFns.format((new Date()).setDate(new Date().getDate() + 1), 'yyyy-MM-dd')}\`.\nTo get the last snapshot before market closure, add the \`after\` keyword to the end of your command (trade and bars ONLY), ex: !stocks GOOG bars after_`;
return message.reply(temp);
temp = `_The markets closed at \`${calendars[0].close}\` and will open again at \`${calendars[0].open}\` on \`${dateFns.format((new Date()).setDate(new Date().getDate() + 1), 'yyyy-MM-dd')}\`.\nTo get the last snapshot before market closure, add the \`after\` keyword to the end of your command (trade and bars ONLY), ex: /stocks GOOG bars after_`;
return interaction.reply(temp);
}
});
})
@@ -111,10 +110,12 @@ function getData(bot, message, args) {
module.exports = {
name: 'stocks',
description: "Have Selmer Bot give you \"current\" stock prices",
async execute(message, args, Discord, Client, bot) {
if (args[0] == 'help' || args.length < 1) {
return message.reply("The command format is: _!stocks <stock_name, 'hours'> <trade, quote, bars> [after]_");
}
getData(bot, message, args);
}
async execute(interaction, Discord, Client, bot) {
getData(bot, interaction);
},
options: [
{name: 'name', description: 'the stock name or "hours" for market hours', type: Constants.ApplicationCommandOptionTypes.STRING, required: true},
{name: 'type', description: 'The type of data to present', type: Constants.ApplicationCommandOptionTypes.STRING, required: true, choices: [ { name: 'trade', value: 'trade' }, { name: 'quote', value: 'quote' }, {name: 'bars', value: 'bars'}]},
{name: 'after', description: 'If the markets are closed, get the last entry', type: Constants.ApplicationCommandOptionTypes.BOOLEAN, required: false},
]
}