Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #21

Merged
merged 3 commits into from
May 28, 2022
Merged

Dev #21

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions commands/ticket/blacklist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = {
name: "blacklist",
description: "Blacklist a user from creating a ticket.",
options: [
{
name: "user",
description: "The user to blacklist",
type: 6,
required: true
},
{
name: "reason",
description: "The reason of blacklist",
type: 3
}
],
permission: "ADMINISTATOR",
run: async(interaction, client) => {
const user = interaction.options.getUser('user');
const reason = interaction.options.getString('reason') || 'No reason provided';

// check if user blacklisted
const isBlacklist = await client.db.get('blacklist', user.id);
if (isBlacklist) {
return interaction.reply({
content: ':x: This user already blacklisted.',
ephemeral: true
})
}

await client.db.set('blacklist', user.id, { user: user.id, reason });

interaction.reply({
content: `✅ ${user} (\`${user.id}\`) has been blacklisted.`
})
}
}
7 changes: 7 additions & 0 deletions commands/ticket/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ module.exports = {
category: "ticket",
usage: "/new",
run: async(interaction, client) => {
const isUserBlacklisted = await client.db.get('blacklist', interaction.user.id);
if (isUserBlacklisted) {
return interaction.reply({
content: ':x: You have been blacklisted from creating tickets.',
ephemeral: true
})
}
const getAllData = await client.db.all("tickets");
const config = await client.db.get('config', interaction.guild.id);
if (!config) {
Expand Down
31 changes: 31 additions & 0 deletions commands/ticket/unblacklist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
name: "unblacklist",
description: "Remove blacklist a user.",
options: [
{
name: "user",
description: "The user to unblacklist",
type: 6,
required: true
}
],
permission: "ADMINISTATOR",
run: async(interaction, client) => {
const user = interaction.options.getUser('user');

// check if user blacklisted
const isBlacklist = await client.db.get('blacklist', user.id);
if (!isBlacklist) {
return interaction.reply({
content: ':x: This user is not blacklisted.',
ephemeral: true
})
}

await client.db.delete('blacklist', user.id);

interaction.reply({
content: `✅ ${user} (\`${user.id}\`) has been unblacklisted.`
})
}
}
9 changes: 2 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,9 @@ require('colors');
});
db.create("tickets");
db.create("config");
db.create("blacklist");
})();

process.on('unhandledRejection', (err) => {
console.error(`Unhandled Rejection: ${err}`.red);
});

process.on('uncaughtException', (err) => {
console.error(`Uncaught Exception: ${err}`.red);
});
process.on('unhandledRejection', console.log)

client.login(process.env.TOKEN);
23 changes: 5 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
{
"name": "fnr-template",
"version": "1.0.0",
"description": "Basic commands handler & slash maker template",
"description": "Ticket Bot",
"main": "index.js",
"scripts": {
"deploy": "node slash.js",
"start": "node .",
"build": "npm i"
},
"repository": {
"type": "git",
"url": "git+https://github.com/FnrDev/fnr-template.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/FnrDev/fnr-template/issues"
},
"homepage": "https://github.com/FnrDev/fnr-template#readme",
"license": "MIT",
"dependencies": {
"@discordjs/rest": "^0.1.0-canary.0",
"@discordjs/rest": "^0.4.1",
"colors": "^1.4.0",
"discord-api-types": "^0.23.1",
"discord.js": "^13.6.0",
"discord-api-types": "^0.33.0",
"discord.js": "^13.7.0",
"dotenv": "^10.0.0",
"humanize-duration": "^3.27.0",
"ms": "^2.1.3",
Expand Down
4 changes: 2 additions & 2 deletions slash.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { Routes } = require('discord-api-types/v10');
const path = require('path');
require('colors')
require('dotenv').config();
Expand All @@ -11,7 +11,7 @@ readdirSync("./commands/").map(async dir => {
commands.push(require(path.join(__dirname, `./commands/${dir}/${cmd}`)))
})
})
const rest = new REST({ version: "9" }).setToken(process.env.TOKEN);
const rest = new REST({ version: "10" }).setToken(process.env.TOKEN);

(async () => {
try {
Expand Down