Compare commits
2 Commits
9d1c6ecfb6
...
9bc73d2630
Author | SHA1 | Date |
---|---|---|
baz | 9bc73d2630 | |
baz | 87fa9e762d |
|
@ -1,6 +1,6 @@
|
|||
clientId=
|
||||
guildId=
|
||||
token=
|
||||
discordClientId=
|
||||
discordGuildId=
|
||||
discordToken=
|
||||
igdbClientId=
|
||||
igdbClientSecret=
|
||||
igdbAccessToken=
|
|
@ -1,14 +0,0 @@
|
|||
const { SlashCommandBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('avatar')
|
||||
.setDescription('Get the avatar URL of the selected user, or your own avatar.')
|
||||
.addUserOption(option => option.setName('user').setDescription('The user\'s avatar to show')),
|
||||
|
||||
async execute(interaction) {
|
||||
const user = interaction.options.getUser('user');
|
||||
if (user) return interaction.reply(`${user.username}'s avatar: ${user.displayAvatarURL()}`);
|
||||
return interaction.reply(`Your avatar: ${interaction.user.displayAvatarURL()}`);
|
||||
},
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
const { SlashCommandBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('ping')
|
||||
.setDescription('Replies with pong!'),
|
||||
|
||||
async execute(interaction) {
|
||||
await interaction.reply('Pong!');
|
||||
},
|
||||
};
|
|
@ -1,32 +0,0 @@
|
|||
const { SlashCommandBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('reload')
|
||||
.setDescription('Reload a command.')
|
||||
.addStringOption(option =>
|
||||
option.setName('command')
|
||||
.setDescription('The command to reload.')
|
||||
.setRequired(true)),
|
||||
|
||||
async execute(interaction) {
|
||||
const commandName = interaction.options.getString('command', true).toLowerCase();
|
||||
const command = interaction.client.commands.get(commandName);
|
||||
|
||||
if (!command) {
|
||||
return interaction.reply(`There is no command with name \`${commandName}\`!`);
|
||||
}
|
||||
|
||||
delete require.cache[require.resolve(`./${command.data.name}.js`)];
|
||||
|
||||
try {
|
||||
interaction.client.commands.delete(command.data.name);
|
||||
const newCommand = require(`./${command.data.name}.js`);
|
||||
interaction.client.commands.set(newCommand.data.name, newCommand);
|
||||
await interaction.reply(`Command \`${newCommand.data.name}\` was reloaded!`);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
await interaction.reply(`There was an error while reloading a command \`${command.data.name}\`:\n\`${error.message}\``);
|
||||
}
|
||||
},
|
||||
};
|
|
@ -1,10 +0,0 @@
|
|||
const { SlashCommandBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('server')
|
||||
.setDescription('Provides information about the server.'),
|
||||
async execute(interaction) {
|
||||
await interaction.reply(`This server is ${interaction.guild.name} and has ${interaction.guild.memberCount} members.`);
|
||||
},
|
||||
};
|
|
@ -1,14 +0,0 @@
|
|||
const { SlashCommandBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('user')
|
||||
.setDescription('Provides information about the user.'),
|
||||
|
||||
async execute(interaction) {
|
||||
// interaction.user is the object representing the user who ran the command
|
||||
// interaction.member is the GuildMember object, which represents the user in the specific guild
|
||||
await interaction.reply(`This command was run by ${interaction.user.username}, who joined on ${interaction.member.joinedAt}.`);
|
||||
|
||||
},
|
||||
};
|
25
dbObjects.js
25
dbObjects.js
|
@ -19,4 +19,29 @@ BeatenGames.belongsTo(Users);
|
|||
Games.hasMany(BeatenGames);
|
||||
BeatenGames.belongsTo(Games);
|
||||
|
||||
Reflect.defineProperty(Users.prototype, 'addUser', {
|
||||
value: async function addUser(userData) {
|
||||
const user = await Users.findOne({
|
||||
where: { user_id: userData.id },
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
return Users.create({ user_id: userData.discord_id, username: userData.username });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reflect.defineProperty(Users.prototype, 'getUser', {
|
||||
value: function getUser(userData) {
|
||||
return Users.findAll({
|
||||
where: { user_id: userData.discord_id },
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
sequelize.sync({ alter: true })
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
module.exports = { Users, Games, BeatenGames };
|
|
@ -27,7 +27,7 @@ for (const folder of commandFolders) {
|
|||
}
|
||||
|
||||
// Construct and prepare an instance of the REST module
|
||||
const rest = new REST().setToken(process.env.token);
|
||||
const rest = new REST().setToken(process.env.discordToken);
|
||||
|
||||
// and deploy your commands!
|
||||
(async () => {
|
||||
|
@ -36,7 +36,7 @@ const rest = new REST().setToken(process.env.token);
|
|||
|
||||
// The put method is used to fully refresh all commands in the guild with the current set
|
||||
const data = await rest.put(
|
||||
Routes.applicationGuildCommands(process.env.clientId, process.env.guildId),
|
||||
Routes.applicationGuildCommands(process.env.discordClientId, process.env.discordGuildId),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue