Skip to content

Commit

Permalink
Changes to block not set up guilds from using the bot
Browse files Browse the repository at this point in the history
  • Loading branch information
Conmmander committed Jul 7, 2024
1 parent fc07c6b commit c31d94d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions commands/update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Placeholder
24 changes: 23 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const clientIntents = [

const { token, applicationID } = require('./config');
const { getRobloxFromDiscord } = require('./util/request');
const { success, error, warn } = require('./util/response');
const { settings } = require('./util/settings');
const db = require('./util/db');

const commands = [
{
Expand All @@ -21,6 +24,8 @@ const rest = new REST({ version: '10' }).setToken(token);
console.log("Starting Aquos Discord Bot");
console.log("A Roblox => Discord linking and toolset bot.");

const guildCache = new Map();

try {
(async () => {
console.log("Started refreshing application slash commands.");
Expand Down Expand Up @@ -48,7 +53,24 @@ client.on('interactionCreate', async interaction => {
return;
}

const { commandName, user, member } = interaction;
const { commandName, user, member, guild } = interaction;
if (!guildCache.has(guild.id)) {
const dbGuild = await db.getGuild(guild.id);
if (dbGuild) {
guildCache.set(guild.id, dbGuild);
} else {
await db.addGuild(guild.id);
await interaction.reply({ embeds: [ error("Please have an admin set the guild up to allow commands to be used!", settings.errorColor.data, "Guild Not Set Up") ] });
return;
}
}

const guildData = guildCache.get(guild.id);
if (guildData.setup === false) {
await interaction.reply({ embeds: [ error("Please have an admin set the guild up to allow commands to be used!", settings.errorColor.data, "Guild Not Set Up") ] });
return;
}

if (commandName === 'update') {
const robloxInfo = await getRobloxFromDiscord(user.id);
try {
Expand Down
22 changes: 22 additions & 0 deletions util/response.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { EmbedBuilder } = require('discord.js');

module.exports = {
success: function success (message, color, title = "Success") {
return new EmbedBuilder()
.setTitle(title)
.setDescription(message)
.setColor(color);
},
error: function error (message, color, title = "Error") {
return new EmbedBuilder()
.setTitle(title)
.setDescription(message)
.setColor(color);
},
warn: function warn (message, color, title = "Warning") {
return new EmbedBuilder()
.setTitle(title)
.setDescription(message)
.setColor(color);
}
}

0 comments on commit c31d94d

Please sign in to comment.