Skip to content

Commit

Permalink
chore: use decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklvh committed Oct 30, 2024
1 parent 130f4bf commit f1c0bb3
Show file tree
Hide file tree
Showing 36 changed files with 222 additions and 328 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
"dependencies": {
"@eslint/eslintrc": "^3.1.0",
"@prisma/client": "^5.21.1",
"@sapphire/decorators": "^6.1.0",
"@sapphire/discord.js-utilities": "^7.3.0",
"@sapphire/fetch": "^3.0.3",
"@sapphire/framework": "^5.2.1",
"@sapphire/plugin-logger": "^4.0.2",
"@sapphire/time-utilities": "^1.7.12",
"@sapphire/utilities": "^3.17.0",
"discord.js": "^14.16.3",
"dotenv": "^16.4.5"
Expand Down
43 changes: 41 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions src/commands/fun/cat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ import { Command } from "@sapphire/framework";
import { fetch, FetchResultTypes } from "@sapphire/fetch";
import { EmbedBuilder } from "discord.js";
import type { APIPetResponse } from "../../utils";
import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: "cat",
description: "shows a cat 😽",
requiredClientPermissions: ["EmbedLinks"],
})
export class CatCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "cat",
description: "shows a cat 😽",
requiredClientPermissions: ["EmbedLinks"],
});
}

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) => builder.setName(this.name).setDescription(this.description),
Expand Down
13 changes: 5 additions & 8 deletions src/commands/fun/coinflip.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { Command } from "@sapphire/framework";
import { EmbedBuilder } from "discord.js";
import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: "coinflip",
description: "flip! shows heads or tails 🪙",
})
export class CoinflipCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "coinflip",
description: "flip! shows heads or tails 🪙",
});
}

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) => builder.setName(this.name).setDescription(this.description),
Expand Down
13 changes: 5 additions & 8 deletions src/commands/fun/dog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import { Command } from "@sapphire/framework";
import { fetch, FetchResultTypes } from "@sapphire/fetch";
import { EmbedBuilder } from "discord.js";
import type { APIPetResponse } from "../../utils";
import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: "dog",
description: "shows a dog 🐶",
})
export class DogCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "dog",
description: "shows a dog 🐶",
});
}

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) => builder.setName(this.name).setDescription(this.description),
Expand Down
15 changes: 6 additions & 9 deletions src/commands/fun/duck.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { Command } from "@sapphire/framework";
import { fetch, FetchResultTypes } from "@sapphire/fetch";
import { EmbedBuilder } from "discord.js";
import type { APIPetInterface } from "../../utils/types/types.js";
import type { APIPetInterface } from "../../utils";
import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: "duck",
description: "shows a duck 🦆",
})
export class DuckCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "duck",
description: "shows a duck 🦆",
});
}

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) => builder.setName(this.name).setDescription(this.description),
Expand Down
13 changes: 5 additions & 8 deletions src/commands/fun/rps.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { Command } from "@sapphire/framework";
import { EmbedBuilder } from "discord.js";
import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: "rps",
description: "will it be: rock, paper, or scissors? 🤔",
})
export class RockPaperScissorsCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "rps",
description: "will it be: rock, paper, or scissors? 🤔",
});
}

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) =>
Expand Down
15 changes: 6 additions & 9 deletions src/commands/misc/avatar.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { Command } from "@sapphire/framework";
import { EmbedBuilder, type ImageExtension, type ImageSize } from "discord.js";
import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: "avatar",
description: "shows a user's avatar",
})
export class AvatarCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "avatar",
description: "shows a user's avatar",
});
}

public override registerApplicationCommands(registry: Command.Registry) {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) =>
builder
Expand Down
15 changes: 6 additions & 9 deletions src/commands/misc/iplookup.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { Command } from "@sapphire/framework";
import { fetch, FetchResultTypes } from "@sapphire/fetch";
import { EmbedBuilder } from "discord.js";
import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: "iplookup",
description: "shows information about an ip address",
})
export class ServerInfoCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "iplookup",
description: "shows information about an ip address",
});
}

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) =>
Expand Down Expand Up @@ -44,7 +41,7 @@ export class ServerInfoCommand extends Command {
}

const res: any = await fetch(
`http://ip-api.com/json/${ip}?fields=156435`,
`https://ip-api.com/json/${ip}?fields=156435`,
FetchResultTypes.JSON
);

Expand Down
13 changes: 5 additions & 8 deletions src/commands/misc/ping.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { Command } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: "ping",
description: "shows latency between bot and discord",
})
export class PingCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "ping",
description: "shows latency between bot and discord",
});
}

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) => builder.setName(this.name).setDescription(this.description),
Expand Down
15 changes: 6 additions & 9 deletions src/commands/misc/serverinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ import {
inlineCode,
time,
} from "discord.js";
import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: "serverinfo",
description: "shows information about the server",
runIn: CommandOptionsRunTypeEnum.GuildAny,
})
export class ServerInfoCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "serverinfo",
description: "shows information about the server",
runIn: CommandOptionsRunTypeEnum.GuildAny,
});
}

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) => builder.setName(this.name).setDescription(this.description),
Expand Down
19 changes: 8 additions & 11 deletions src/commands/misc/setnick.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { Command, CommandOptionsRunTypeEnum } from "@sapphire/framework";
import { EmbedBuilder, PermissionFlagsBits } from "discord.js";
import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: "setnick",
description: "set the nickname of a user",
requiredClientPermissions: [PermissionFlagsBits.ManageNicknames],
requiredUserPermissions: [PermissionFlagsBits.ManageNicknames],
runIn: CommandOptionsRunTypeEnum.GuildAny,
})
export class SetNickCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "setnick",
description: "set the nickname of a user",
requiredClientPermissions: [PermissionFlagsBits.ManageNicknames],
requiredUserPermissions: [PermissionFlagsBits.ManageNicknames],
runIn: CommandOptionsRunTypeEnum.GuildAny,
});
}

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) =>
Expand Down
13 changes: 5 additions & 8 deletions src/commands/misc/whois.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { Command } from "@sapphire/framework";
import { EmbedBuilder } from "discord.js";
import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: "whois",
description: "shows information about a user",
})
export class WhoisCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "whois",
description: "shows information about a user",
});
}

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) =>
Expand Down
21 changes: 9 additions & 12 deletions src/commands/moderation/ban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@ import {
} from "discord.js";
import { ModerationType } from "@prisma/client";
import { handleInfraction } from "../../utils";

import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: "ban",
description: "ban a member 🔨",
requiredUserPermissions: [PermissionFlagsBits.BanMembers],
requiredClientPermissions: [PermissionFlagsBits.BanMembers],
runIn: CommandOptionsRunTypeEnum.GuildAny,
})
export class BanCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "ban",
description: "ban a member 🔨",
requiredUserPermissions: [PermissionFlagsBits.BanMembers],
requiredClientPermissions: [PermissionFlagsBits.BanMembers],
runIn: CommandOptionsRunTypeEnum.GuildAny,
});
}

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) => {
Expand Down
Loading

0 comments on commit f1c0bb3

Please sign in to comment.