Basic User and Guild registration
This commit is contained in:
@@ -1,12 +1,34 @@
|
||||
require("dotenv").config();
|
||||
const { REST } = require("@discordjs/rest");
|
||||
const { Routes } = require("discord-api-types/v9")
|
||||
const { Guild } = require("../models");
|
||||
|
||||
module.exports = {
|
||||
name: "interactionCreate",
|
||||
async execute (interaction) {
|
||||
if (!interaction.isCommand()) return;
|
||||
|
||||
const guild = await interaction.guild;
|
||||
//check if guild exists in database
|
||||
let guildData = await Guild.findOne({
|
||||
where: {
|
||||
guildID: guild.id
|
||||
}
|
||||
});
|
||||
|
||||
if (!guildData) {
|
||||
//create guild in database
|
||||
await Guild.create({
|
||||
guildID: guild.id,
|
||||
ownerID: guild.ownerId,
|
||||
});
|
||||
//send guild registered message to the interations channel
|
||||
interaction.channel.send({
|
||||
content: `Guild ${guild.name} registered`,
|
||||
ephemeral: false
|
||||
});
|
||||
|
||||
}
|
||||
const command = interaction.client.commands.get(interaction.commandName);
|
||||
|
||||
if (!command) return;
|
||||
|
||||
Reference in New Issue
Block a user