Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
fix some commands + allow while banned feat
Browse files Browse the repository at this point in the history
  • Loading branch information
wdhdev committed Jul 24, 2023
1 parent 00af74c commit 74c08dd
Show file tree
Hide file tree
Showing 46 changed files with 126 additions and 81 deletions.
1 change: 1 addition & 0 deletions src/classes/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default class {
public requiredRoles: Roles;
public cooldown: number;
public enabled: boolean;
public allowWhileBanned: boolean;
public staffOnly: boolean;
public deferReply: boolean;
public ephemeral: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/classes/ContextCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default class {
public requiredRoles: Roles;
public cooldown: number;
public enabled: boolean;
public allowWhileBanned: boolean;
public staffOnly: boolean;
public deferReply: boolean;
public ephemeral: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/commands/dev/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const command: Command = {
requiredRoles: new Roles(["dev"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/dev/announce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const command: Command = {
requiredRoles: new Roles(["dev"]),
cooldown: 60,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: false,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/dev/delete-webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const command: Command = {
requiredRoles: new Roles(["dev"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/dev/manual-register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const command: Command = {
requiredRoles: new Roles(["dev"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/dev/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const command: Command = {
requiredRoles: new Roles(["dev"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/dev/unwhitelist-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const command: Command = {
requiredRoles: new Roles(["dev"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/dev/whitelist-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const command: Command = {
requiredRoles: new Roles(["dev"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/guild/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 10,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/guild/blocked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 10,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down
11 changes: 8 additions & 3 deletions src/commands/guild/delete-guild-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 120,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand All @@ -35,9 +36,13 @@ const command: Command = {
}

const confirmation = new Discord.EmbedBuilder()
.setColor(client.config_embeds.default)
.setTitle("Confirmation")
.setDescription("Are you sure you want to delete all data associated with this guild?\n\nThe global chat channel will be **deregistered** and any webhooks will be **deleted**.\n**This cannot be undone.**")
.setColor(client.config_embeds.error)
.setAuthor({ name: interaction.guild.name, iconURL: interaction.guild.iconURL({ extension: "png", forceStatic: false }) })
.setTitle("Delete Guild Data")
.setDescription("Are you sure you want to delete all data associated with this guild?\n**This cannot be undone.**")
.addFields (
{ name: "What will be deleted?", value: "📝 Register Data\n🪝 Webhooks" }
)
.setTimestamp()

const actions = new Discord.ActionRowBuilder()
Expand Down
1 change: 1 addition & 0 deletions src/commands/guild/deregister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 60,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: false,
Expand Down
1 change: 1 addition & 0 deletions src/commands/guild/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 20,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/guild/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 120,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: false,
Expand Down
1 change: 1 addition & 0 deletions src/commands/guild/unblock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 10,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/info/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 5,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/info/developers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 5,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/info/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 5,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/info/moderators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 5,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/info/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 10,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/mod/appeal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const command: Command = {
requiredRoles: new Roles(["mod"]),
cooldown: 5,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/mod/appeals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const command: Command = {
requiredRoles: new Roles(["mod"]),
cooldown: 10,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/mod/ban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const command: Command = {
requiredRoles: new Roles(["mod"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/mod/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const command: Command = {
requiredRoles: new Roles(["mod"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/mod/unban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const command: Command = {
requiredRoles: new Roles(["mod"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/mod/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const command: Command = {
requiredRoles: new Roles(["mod"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/owner/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const command: Command = {
requiredRoles: new Roles(["owner"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/owner/donator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const command: Command = {
requiredRoles: new Roles(["owner"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/owner/eval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const command: Command = {
requiredRoles: new Roles(["owner"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/owner/immunity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const command: Command = {
requiredRoles: new Roles(["owner"]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
30 changes: 26 additions & 4 deletions src/commands/user/delete-my-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import Roles from "../../classes/Roles";
import { CommandInteraction } from "discord.js";

import { emojis as emoji } from "../../config";
import { Octokit } from "@octokit/core";

import GitHubUser from "../../models/GitHubUser";
import User from "../../models/User";

const command: Command = {
Expand All @@ -16,12 +18,13 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 120,
enabled: true,
allowWhileBanned: true,
staffOnly: false,
deferReply: true,
ephemeral: true,
async execute(interaction: CommandInteraction, client: ExtendedClient, Discord: any) {
try {
if(!await User.exists({ _id: interaction.user.id })) {
if(!await User.exists({ _id: interaction.user.id }) && !await GitHubUser.exists({ _id: interaction.user.id })) {
const error = new Discord.EmbedBuilder()
.setColor(client.config_embeds.error)
.setDescription(`${emoji.cross} There is no data associated with your account!`)
Expand All @@ -31,9 +34,13 @@ const command: Command = {
}

const embed = new Discord.EmbedBuilder()
.setColor(client.config_embeds.default)
.setTitle("Confirmation")
.setDescription("Are you sure you want to delete all data associated with your account?\n\nEverything including your **roles** will be removed.\n**This cannot be undone.**")
.setColor(client.config_embeds.error)
.setTitle("Delete My Data")
.setDescription("Are you sure you want to delete all data associated with your account?\n**This cannot be undone.**")
.addFields (
{ name: "What will be deleted?", value: "🎭 Roles\n🔗 Linked Accounts", inline: true },
{ name: "What will not be deleted?", value: "🔨 Ban Data\n💬 Messages\n⛔ Blocked Messages", inline: true }
)
.setTimestamp()

const actions = new Discord.ActionRowBuilder()
Expand Down Expand Up @@ -65,6 +72,21 @@ const command: Command = {
if(c.customId === `delete-${interaction.id}`) {
collector.stop();

const githubData = await GitHubUser.findOne({ _id: interaction.user.id });

if(githubData) {
try {
const octokit = new Octokit({ auth: githubData.token });

await octokit.request("DELETE /applications/{client_id}/grant", {
client_id: process.env.github_client_id,
access_token: githubData.token
})
} catch {}

await githubData.delete();
}

await User.findOneAndDelete({ _id: interaction.user.id });

const deleted = new Discord.EmbedBuilder()
Expand Down
3 changes: 2 additions & 1 deletion src/commands/user/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 10,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down Expand Up @@ -161,7 +162,7 @@ const command: Command = {
try {
const octokit = new Octokit({ auth: data.token });

await octokit.request('DELETE /applications/{client_id}/grant', {
await octokit.request("DELETE /applications/{client_id}/grant", {
client_id: process.env.github_client_id,
access_token: data.token
})
Expand Down
1 change: 1 addition & 0 deletions src/commands/user/me.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 0,
enabled: true,
allowWhileBanned: false,
staffOnly: true,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/user/my-roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 10,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/user/my-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 10,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/commands/user/suggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const command: Command = {
requiredRoles: new Roles([]),
cooldown: 10,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down
1 change: 1 addition & 0 deletions src/context-menu/message/Delete Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const command: ContextCommand = {
requiredRoles: new Roles([]),
cooldown: 5,
enabled: true,
allowWhileBanned: false,
staffOnly: false,
deferReply: true,
ephemeral: true,
Expand Down
Loading

0 comments on commit 74c08dd

Please sign in to comment.