Skip to content

Commit

Permalink
perms are fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
trent-001 committed Jul 23, 2024
1 parent 3bfebaa commit b914126
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 41 deletions.
4 changes: 2 additions & 2 deletions commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export default {
.setName("keep_vod")
.setDescription("Show the vod from that live")
.setRequired(false)
),
permissions: [PermissionsBitField.Flags.Administrator],
)
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator),
async execute(inter: ChatInputCommandInteraction) {
try {
await inter.deferReply({
Expand Down
9 changes: 7 additions & 2 deletions commands/list.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
import {
ChatInputCommandInteraction,
PermissionsBitField,
SlashCommandBuilder,
} from "discord.js";
import { db } from "../db";
import * as schema from "../db/schema";
import { eq } from "drizzle-orm";
export default {
data: new SlashCommandBuilder()
.setName("list")
.setDescription("List all twitch users"),
.setDescription("List all twitch users")
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator),
async execute(inter: ChatInputCommandInteraction) {
try {
await inter.deferReply({
Expand Down
4 changes: 2 additions & 2 deletions commands/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export default {
.setName("channel")
.setDescription("Channel to remove it from")
.setRequired(true)
),
permissions: [PermissionsBitField.Flags.Administrator],
)
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator),
async execute(inter: ChatInputCommandInteraction) {
try {
await inter.deferReply({
Expand Down
6 changes: 4 additions & 2 deletions commands/uptime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import { discord } from "..";
export default {
data: new SlashCommandBuilder()
.setName("uptime")
.setDescription("Check the uptime"),
.setDescription("Check the uptime")
.setDefaultMemberPermissions(
PermissionsBitField.Flags.UseApplicationCommands
),
cooldown: 3,
permissions: [PermissionsBitField.Flags.UseApplicationCommands],
async execute(inter: ChatInputCommandInteraction) {
try {
await inter.deferReply();
Expand Down
12 changes: 1 addition & 11 deletions events/interactionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { AddButtonDataTwitch, commands, discord } from "..";
import { db } from "../db";
import * as schema from "../db/schema";
import { randomUUID } from "crypto";
import { checkPermissions, PermissionResult } from "../lib/checkPermissions";
discord.on(
Events.InteractionCreate,
async (interaction: Interaction): Promise<any> => {
Expand Down Expand Up @@ -88,16 +87,7 @@ discord.on(

if (!command) return;
try {
const permissionsCheck: PermissionResult = await checkPermissions(
command,
interaction
);

if (permissionsCheck.result) {
command.execute(interaction as ChatInputCommandInteraction);
} else {
throw new Error(permissionsCheck.missing.join(", "));
}
command.execute(interaction as ChatInputCommandInteraction);
} catch (error: any) {
console.error(error);
if (error.message.includes("permissions")) {
Expand Down
22 changes: 0 additions & 22 deletions lib/checkPermissions.ts

This file was deleted.

0 comments on commit b914126

Please sign in to comment.