Skip to content

Commit

Permalink
Add ban command to moderation bot
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeName-Anti committed Aug 13, 2024
1 parent 6c6d237 commit 98cc869
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/misc/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function startBot() {
message.reply('An error occurred while verifying the user.');
}
}

if (args[0] === '!unban' && args[1]) {
try {
const response = await fetch(`${API_BASE_URL}/api/unban?handle=${args[1]}`, {
Expand All @@ -92,6 +93,30 @@ function startBot() {
message.reply('An error occurred while unbanning the user.');
}
}

if (args[0] === '!ban' && args[1]) {
try {
let userId = args[1];

const response = await fetch(`${API_BASE_URL}/api/ban`, {
method: 'POST',
headers: {
Authorization: ADMIN_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({ userId })
});

if (response.ok) {
message.reply('Success');
} else {
message.reply(`Error: ${response.status} | ${response.statusText}`);
}
} catch (error) {
console.error('Error banning user:', error);
message.reply('An error occurred while banning the user.');
}
}
});
client.on('interactionCreate', async (interaction) => {
try {
Expand Down

0 comments on commit 98cc869

Please sign in to comment.