-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from TopicBotList/dev
Dev
- Loading branch information
Showing
16 changed files
with
144 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const { MessageEmbed, ApplicationCommandOptionType } = require("discord.js"); | ||
|
||
module.exports = { | ||
name: "eval", | ||
description: "Evaluate JavaScript code.", | ||
disabled: false, | ||
options: [ | ||
{ | ||
name: "code", | ||
type: ApplicationCommandOptionType.String, | ||
required: true, | ||
description: "Please provide the JavaScript code to evaluate.", | ||
}, | ||
], | ||
run: async (client, interaction, args) => { | ||
const code = interaction.options.getString("code"); | ||
|
||
try { | ||
let result = eval(code); | ||
result = result instanceof Promise ? await result : result; | ||
|
||
const evalEmbed = new MessageEmbed() | ||
.setColor(client.color) | ||
.setFooter({ | ||
text: client.footer, | ||
}) | ||
.setTitle("Evaluation Result") | ||
.addField("Input", `\`\`\`js\n${code}\n\`\`\``) | ||
.addField("Output", `\`\`\`js\n${result}\n\`\`\``); | ||
|
||
interaction.reply({ embeds: [evalEmbed] }); | ||
} catch (error) { | ||
const errorEmbed = new MessageEmbed() | ||
.setColor("#FF0000") | ||
.setFooter({ | ||
text: client.footer, | ||
}) | ||
.setTitle("Error Occurred") | ||
.setDescription(`\`\`\`js\n${error}\n\`\`\``); | ||
|
||
interaction.reply({ embeds: [errorEmbed] }); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const { MessageEmbed } = require("discord.js"); | ||
const fetch = require("node-fetch"); | ||
const config = require("../../../config/config.js"); | ||
|
||
module.exports = { | ||
name: "all-partners", | ||
description: "Tells you about all our partners.", | ||
cooldown: "3", | ||
disabled: false, | ||
run: async (client, interaction, args) => { | ||
try { | ||
const response = await fetch(`https://api.topiclist.xyz/partners/@all`); | ||
const partners = await response.json(); | ||
|
||
if (!Array.isArray(partners)) { | ||
throw new Error("Partners data is not in the expected format."); | ||
} | ||
|
||
const partnerEmbed = new MessageEmbed() | ||
.setTitle("Our Partners") | ||
.setColor(client.color) | ||
.setFooter(client.footer); | ||
|
||
partners.forEach((partner) => { | ||
partnerEmbed.addField( | ||
partner.title, | ||
`[${partner.text}](${partner.link})`, | ||
); | ||
}); | ||
|
||
return interaction.reply({ | ||
embeds: [partnerEmbed], | ||
}); | ||
} catch (error) { | ||
console.error("Error fetching partners:", error); | ||
if ( | ||
error instanceof TypeError && | ||
error.message.startsWith("body used already") | ||
) { | ||
console.error("Response body already consumed."); | ||
} else { | ||
console.error("API Response:", await response.text()); | ||
} | ||
return interaction.reply( | ||
"Sorry, I couldn't fetch our partners at the moment.", | ||
); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters