Added support for type commands
This commit is contained in:
parent
abb422c7f1
commit
4c853ae503
3 changed files with 39 additions and 14 deletions
|
@ -5,9 +5,19 @@ const guildId = process.env.GUILD_ID;
|
|||
const token = process.env.TOKEN;
|
||||
|
||||
const commands = [
|
||||
new SlashCommandBuilder().setName('ping').setDescription('Replies with pong!'),
|
||||
new SlashCommandBuilder().setName('server').setDescription('Replies with server info!'),
|
||||
new SlashCommandBuilder().setName('user').setDescription('Replies with user info!'),
|
||||
new SlashCommandBuilder()
|
||||
.setName('generate')
|
||||
.setDescription('Generate something.')
|
||||
.addStringOption(option =>
|
||||
option.setName('type')
|
||||
.setDescription('The type of thing to generate.')
|
||||
.setRequired(true)
|
||||
.addChoices(
|
||||
{ name: 'Host', value: 'host' },
|
||||
{ name: 'Gang', value: 'gang' },
|
||||
{ name: 'Corporation', value: 'corporation' },
|
||||
)
|
||||
)
|
||||
]
|
||||
.map(command => command.toJSON());
|
||||
|
||||
|
@ -17,6 +27,10 @@ rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
|
|||
.then((data) => console.log('Removed all commands from guilds'))
|
||||
.catch(console.error);
|
||||
|
||||
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
|
||||
.then((data) => console.log(`Successfully registered ${data.length} application commands.`))
|
||||
.catch(console.error);
|
||||
rest.put(Routes.applicationCommands(clientId), { body: [] })
|
||||
.then((data) => console.log(`Removed all global commands`))
|
||||
.catch(console.error);
|
||||
|
||||
rest.put(Routes.applicationCommands(clientId), { body: commands })
|
||||
.then((data) => console.log(`Added ${data.length} commands to global`))
|
||||
.catch(console.error);
|
15
html-to-png.js
Normal file
15
html-to-png.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { Puppeteer } from "puppeteer";
|
||||
|
||||
export default async function (html) {
|
||||
|
||||
const browser = await Puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
|
||||
await page.setContent(html);
|
||||
const file = await page.screenshot({ type: "png" });
|
||||
|
||||
await page.close();
|
||||
await browser.close();
|
||||
|
||||
return file;
|
||||
}
|
12
index.js
12
index.js
|
@ -8,20 +8,16 @@ const client = new Client({
|
|||
})
|
||||
|
||||
client.once('ready', () => {
|
||||
console.log('Ready!');
|
||||
console.log('Bot is Ready!');
|
||||
});
|
||||
|
||||
client.on('interactionCreate', async interaction => {
|
||||
if (!interaction.isCommand()) return;
|
||||
|
||||
const commandName = interaction.commandName;
|
||||
let commandName = interaction.commandName;
|
||||
|
||||
if (commandName === 'ping') {
|
||||
await interaction.reply('Pong!');
|
||||
} else if (commandName === 'server') {
|
||||
await interaction.reply(`Server name: ${interaction.guild.name}\nTotal members: ${interaction.guild.memberCount}`);
|
||||
} else if (commandName === 'user') {
|
||||
await interaction.reply(`Your tag: ${interaction.user.tag}\nYour id: ${interaction.user.id}`);
|
||||
if (commandName === "generate") {
|
||||
await interaction.reply(`Generating ${interaction.options.getString('type')}`);
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue