Fixed some remaining changes from the transition to Slash commands

This commit is contained in:
ION606
2022-10-06 12:41:15 -04:00
parent b30fdc9e7f
commit d69e7e0479
12 changed files with 151 additions and 23 deletions
+11 -10
View File
@@ -18,10 +18,11 @@ getAllCoins();
module.exports = {
name: 'crypto',
description: 'Get the prices for most cryptocurrencies!',
async execute(message, args, Discord, Client, bot) {
if (args.length < 1 || args[0] == 'help') {
return message.reply("Please specify at least one cryptocurrency (_ex: !crypto BTC_) or list all currencies (_!crypto list_)");
} else if (args[0] == 'list') {
async execute(interaction, Discord, Client, bot) {
const args = interaction.options.data;
if (args.length < 1 || args[0].value == 'help') {
return interaction.reply("Please specify at least one cryptocurrency (_ex: !crypto BTC_) or list all currencies (_!crypto list_)");
} else if (args[0].value == 'list') {
try {
return new Promise((resolve, reject) => {
let temp = "```Name --> Symbol\n\n";
@@ -32,11 +33,11 @@ module.exports = {
resolve(temp);
}).then((temp) => {
message.reply(temp);
interaction.reply(temp);
})
} catch (err) {
console.error(err);
return message.reply("Uh Oh! There's been an error!");
return interaction.reply("Uh Oh! There's been an error!");
}
}
@@ -47,7 +48,7 @@ module.exports = {
var datacc = data.data.tickers.filter(t => t.target == 'USD');
const temp = datacc.filter(t => t.base == args[0]);
const temp = datacc.filter(t => t.base == args[0].value);
const res = temp.length == 0 ? [] : temp[0];
//price: res.last, symbol: base, trust score: trust_score
@@ -67,11 +68,11 @@ module.exports = {
.setTimestamp()
.setFooter({ text: 'Selmer Bot uses CoinGecko for cryptocurrency information'});
message.reply({ embeds: [embd] });
interaction.reply({ embeds: [embd] });
} catch (err) {
console.error(err);
return message.reply("Uh Oh! There's been an error!");
return interaction.reply("Uh Oh! There's been an error!");
}
},
options: [{name: 'qeury', description: 'Name or List', type: Constants.ApplicationCommandOptionTypes.STRING, required: true}]
options: [{name: 'query', description: 'Name or List', type: Constants.ApplicationCommandOptionTypes.STRING, required: true}]
}
+19
View File
@@ -1,6 +1,18 @@
const hastebin = require("hastebin-gen");
const { addComplaintButton } = require('../dev only/submitcomplaint');
const { Constants } = require('discord.js');
const { URL } = require("url");
function isValidUrl(s) {
try {
new URL(s);
return true;
} catch (err) {
return false;
}
};
module.exports ={
name: "scrape",
@@ -9,6 +21,13 @@ module.exports ={
const axios = require('axios');
// const cheerio = require('cheerio');
const url = interaction.options.data[0].value;
if (!isValidUrl(url)) {
return interaction.reply("Please enter a valid url").catch((err) => {
interaction.channel.send("Please enter a valid url");
});
}
axios(url)
.then(async response => {
const html = response.data;