Basic User and Guild registration

This commit is contained in:
2022-04-17 16:07:57 +02:00
parent be2991cd50
commit 3dddae6dca
7 changed files with 142 additions and 6 deletions

32
commands/register.js Normal file
View File

@@ -0,0 +1,32 @@
//User registration
const { SlashCommandBuilder } = require("@discordjs/builders");
const { User } = require("../models");
module.exports = {
data: new SlashCommandBuilder()
.setName("register")
.setDescription("Register yourself"),
async execute(interaction) {
let user = await User.findOne({
where: {
userID: interaction.user.id
}
});
if (user) {
interaction.reply({
content: "You are already registered",
ephemeral: true
});
} else {
await User.create({
userID: interaction.user.id,
banned: false,
registredAt: new Date()
});
interaction.reply({
content: "You are now registered",
ephemeral: false
});
}
}
}

24
commands/userlist.js Normal file
View File

@@ -0,0 +1,24 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { User } = require("../models");
module.exports = {
data: new SlashCommandBuilder()
.setName("userlist")
.setDescription("List all users"),
async execute(interaction) {
let users = await User.findAll();
let userList = "";
for (let i = 0; i < users.length; i++) {
let username = await interaction.client.users.fetch(users[i].userID);
userList += `${username.username}#${username.discriminator}`;
}
if (userList === "") {
userList = "No users found";
}
interaction.reply({
content: userList,
ephemeral: false
});
}
}