server registration and subscription
This commit is contained in:
@@ -1,90 +1,106 @@
|
||||
const { REST, Routes, SlashCommandBuilder } = require('discord.js');
|
||||
require('dotenv').config();
|
||||
const { REST, Routes, SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
||||
require("dotenv").config();
|
||||
|
||||
const commands = [
|
||||
new SlashCommandBuilder()
|
||||
.setName('ping')
|
||||
.setDescription('Replies with Pong!'),
|
||||
new SlashCommandBuilder()
|
||||
.setName('finduser')
|
||||
.setDescription('Find a user by username')
|
||||
.addStringOption(option =>
|
||||
option.setName('username')
|
||||
.setDescription('The username to search for')
|
||||
.setRequired(true))
|
||||
.addStringOption(option =>
|
||||
option.setName('game')
|
||||
.setDescription('Specify a game to view stats for')
|
||||
.setRequired(false)),
|
||||
new SlashCommandBuilder()
|
||||
.setName('matchhistory')
|
||||
.setDescription('View match history')
|
||||
.addStringOption(option =>
|
||||
option.setName('username')
|
||||
.setDescription('The username to search for')
|
||||
.setRequired(true))
|
||||
.addStringOption(option =>
|
||||
option.setName('game')
|
||||
.setDescription('Filter by game')
|
||||
.setRequired(false)),
|
||||
// New subscription commands
|
||||
new SlashCommandBuilder()
|
||||
.setName('subscribe')
|
||||
.setDescription('Subscribe to game notifications')
|
||||
.addStringOption(option =>
|
||||
option.setName('game')
|
||||
.setDescription('Game to subscribe to')
|
||||
.setRequired(true)
|
||||
.addChoices(
|
||||
{ name: 'Big Ballers VR', value: 'Big Ballers VR' },
|
||||
{ name: 'Blacktop Hoops', value: 'Blacktop Hoops' },
|
||||
{ name: 'Breachers', value: 'Breachers' },
|
||||
{ name: 'Echo Arena', value: 'Echo Arena' },
|
||||
{ name: 'Echo Combat', value: 'Echo Combat' },
|
||||
{ name: 'Gun Raiders', value: 'Gun Raiders' },
|
||||
{ name: 'Nock', value: 'Nock' },
|
||||
{ name: 'VAIL', value: 'VAIL' }
|
||||
))
|
||||
.addChannelOption(option =>
|
||||
option.setName('channel')
|
||||
.setDescription('Channel for notifications')
|
||||
.setRequired(true)),
|
||||
new SlashCommandBuilder()
|
||||
.setName('unsubscribe')
|
||||
.setDescription('Unsubscribe from game notifications')
|
||||
.addStringOption(option =>
|
||||
option.setName('game')
|
||||
.setDescription('Game to unsubscribe from')
|
||||
.setRequired(true)
|
||||
.addChoices(
|
||||
{ name: 'Big Ballers VR', value: 'Big Ballers VR' },
|
||||
{ name: 'Blacktop Hoops', value: 'Blacktop Hoops' },
|
||||
{ name: 'Breachers', value: 'Breachers' },
|
||||
{ name: 'Echo Arena', value: 'Echo Arena' },
|
||||
{ name: 'Echo Combat', value: 'Echo Combat' },
|
||||
{ name: 'Gun Raiders', value: 'Gun Raiders' },
|
||||
{ name: 'Nock', value: 'Nock' },
|
||||
{ name: 'VAIL', value: 'VAIL' }
|
||||
)),
|
||||
new SlashCommandBuilder()
|
||||
.setName('list_subscriptions')
|
||||
.setDescription('List all game subscriptions for this server')
|
||||
new SlashCommandBuilder()
|
||||
.setName("ping")
|
||||
.setDescription("Replies with Pong!"),
|
||||
new SlashCommandBuilder()
|
||||
.setName("finduser")
|
||||
.setDescription("Find a user by username")
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("username")
|
||||
.setDescription("The username to search for")
|
||||
.setRequired(true)
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("game")
|
||||
.setDescription("Specify a game to view stats for")
|
||||
.setRequired(false)
|
||||
),
|
||||
new SlashCommandBuilder()
|
||||
.setName("matchhistory")
|
||||
.setDescription("View match history")
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("username")
|
||||
.setDescription("The username to search for")
|
||||
.setRequired(true)
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
option.setName("game").setDescription("Filter by game").setRequired(false)
|
||||
),
|
||||
new SlashCommandBuilder()
|
||||
.setName("subscribe")
|
||||
.setDescription("Subscribe to game notifications")
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("game")
|
||||
.setDescription("Game to subscribe to")
|
||||
.setRequired(true)
|
||||
.addChoices(
|
||||
{ name: "Big Ballers VR", value: "Big Ballers VR" },
|
||||
{ name: "Blacktop Hoops", value: "Blacktop Hoops" },
|
||||
{ name: "Breachers", value: "Breachers" },
|
||||
{ name: "Echo Arena", value: "Echo Arena" },
|
||||
{ name: "Echo Combat", value: "Echo Combat" },
|
||||
{ name: "Gun Raiders", value: "Gun Raiders" },
|
||||
{ name: "Nock", value: "Nock" },
|
||||
{ name: "VAIL", value: "VAIL" }
|
||||
)
|
||||
)
|
||||
.addChannelOption((option) =>
|
||||
option
|
||||
.setName("channel")
|
||||
.setDescription("Channel for notifications")
|
||||
.setRequired(true)
|
||||
),
|
||||
new SlashCommandBuilder()
|
||||
.setName("unsubscribe")
|
||||
.setDescription("Unsubscribe from game notifications")
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("game")
|
||||
.setDescription("Game to unsubscribe from")
|
||||
.setRequired(true)
|
||||
.addChoices(
|
||||
{ name: "Big Ballers VR", value: "Big Ballers VR" },
|
||||
{ name: "Blacktop Hoops", value: "Blacktop Hoops" },
|
||||
{ name: "Breachers", value: "Breachers" },
|
||||
{ name: "Echo Arena", value: "Echo Arena" },
|
||||
{ name: "Echo Combat", value: "Echo Combat" },
|
||||
{ name: "Gun Raiders", value: "Gun Raiders" },
|
||||
{ name: "Nock", value: "Nock" },
|
||||
{ name: "VAIL", value: "VAIL" }
|
||||
)
|
||||
),
|
||||
new SlashCommandBuilder()
|
||||
.setName("register_server")
|
||||
.setDescription("Register this Discord server with BattleBot")
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
||||
new SlashCommandBuilder()
|
||||
.setName("list_subscriptions")
|
||||
.setDescription("List all game subscriptions for this server"),
|
||||
];
|
||||
|
||||
const rest = new REST({ version: '10' }).setToken(process.env.BOT_TOKEN);
|
||||
const rest = new REST({ version: "10" }).setToken(process.env.BOT_TOKEN);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
console.log('Started refreshing application (/) commands.');
|
||||
console.log('Commands to be deployed:', commands.map(cmd => cmd.name));
|
||||
try {
|
||||
console.log("Started refreshing application (/) commands.");
|
||||
console.log(
|
||||
"Commands to be deployed:",
|
||||
commands.map((cmd) => cmd.name)
|
||||
);
|
||||
|
||||
await rest.put(
|
||||
Routes.applicationCommands(process.env.CLIENT_ID),
|
||||
{ body: commands.map(command => command.toJSON()) },
|
||||
);
|
||||
await rest.put(Routes.applicationCommands(process.env.CLIENT_ID), {
|
||||
body: commands.map((command) => command.toJSON()),
|
||||
});
|
||||
|
||||
console.log('Successfully reloaded application (/) commands.');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
console.log("Successfully reloaded application (/) commands.");
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user