Skip to content

Commit

Permalink
chore: remove decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklvh committed Jul 13, 2024
1 parent 382f2ee commit 657a3ad
Show file tree
Hide file tree
Showing 33 changed files with 814 additions and 562 deletions.
21 changes: 13 additions & 8 deletions src/commands/fun/cat.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import { Command } from "@sapphire/framework";
import { fetch, FetchResultTypes } from "@sapphire/fetch";
import { EmbedBuilder } from "discord.js";
import type { APIPetResponse } from "../../types/index.js";
import { ApplyOptions } from "@sapphire/decorators";
import type { APIPetResponse } from "../../utils";

@ApplyOptions<Command.Options>({
name: "cat",
description: "shows a cat 😽",
})
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)
registry.registerChatInputCommand(
(builder) => builder.setName(this.name).setDescription(this.description),
{ idHints: ["1169746949239476275"] }
);
}

Expand Down
18 changes: 11 additions & 7 deletions src/commands/fun/coinflip.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { Command } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import { EmbedBuilder } from "discord.js";

@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)
registry.registerChatInputCommand(
(builder) => builder.setName(this.name).setDescription(this.description),
{ idHints: ["1171942952705208390"] }
);
}

Expand Down
20 changes: 12 additions & 8 deletions src/commands/fun/dog.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { Command } from "@sapphire/framework";
import { fetch, FetchResultTypes } from "@sapphire/fetch";
import { EmbedBuilder } from "discord.js";
import type { APIPetResponse } from "../../types/index.js";
import { ApplyOptions } from "@sapphire/decorators";
import type { APIPetResponse } from "../../utils";

@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)
registry.registerChatInputCommand(
(builder) => builder.setName(this.name).setDescription(this.description),
{ idHints: ["1169750644710703225"] }
);
}

Expand Down
20 changes: 12 additions & 8 deletions src/commands/fun/duck.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { Command } from "@sapphire/framework";
import { fetch, FetchResultTypes } from "@sapphire/fetch";
import { EmbedBuilder } from "discord.js";
import { ApplyOptions } from "@sapphire/decorators";
import type { APIPetInterface } from "../../types/index.js";
import type { APIPetInterface } from "../../utils/types/types.js";

@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)
registry.registerChatInputCommand(
(builder) => builder.setName(this.name).setDescription(this.description),
{ idHints: ["1169732840691355659"] }
);
}

Expand Down
63 changes: 34 additions & 29 deletions src/commands/fun/rps.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
import { Command } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import { EmbedBuilder } from "discord.js";

@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) =>
builder
.setName(this.name)
.setDescription(this.description)
.addStringOption((option) =>
option
.setName("choice")
.setDescription("your choice of rock, paper, or scissors")
.setRequired(true)
.setChoices(
{
name: "Rock",
value: "Rock",
},
{
name: "Paper",
value: "Paper",
},
{
name: "Scissors",
value: "Scissors",
}
)
)
registry.registerChatInputCommand(
(builder) =>
builder
.setName(this.name)
.setDescription(this.description)
.addStringOption((option) =>
option
.setName("choice")
.setDescription("your choice of rock, paper, or scissors")
.setRequired(true)
.setChoices(
{
name: "Rock",
value: "Rock",
},
{
name: "Paper",
value: "Paper",
},
{
name: "Scissors",
value: "Scissors",
}
)
),
{ idHints: ["1171945619875696672"] }
);
}

Expand Down
95 changes: 50 additions & 45 deletions src/commands/misc/avatar.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,58 @@
import { Command } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import { EmbedBuilder, type ImageExtension, type ImageSize } from "discord.js";

@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) {
registry.registerChatInputCommand((builder) =>
builder
.setName(this.name)
.setDescription(this.description)
.addUserOption((option) =>
option
.setName("user")
.setDescription("the user to show the avatar of")
.setRequired(false)
)
.addNumberOption((option) =>
option
.setName("size")
.setDescription("the size of the avatar")
.setRequired(false)
.setChoices(
{ name: "16", value: 16 },
{ name: "32", value: 32 },
{ name: "64", value: 64 },
{ name: "128", value: 128 },
{ name: "256", value: 256 },
{ name: "512", value: 512 },
{ name: "1024", value: 1024 },
{ name: "2048", value: 2048 },
{ name: "4096", value: 4096 }
)
)
.addStringOption((option) =>
option
.setName("format")
.setDescription("the format of the avatar")
.setRequired(false)
.setChoices(
{ name: "webp", value: "webp" },
{ name: "png", value: "png" },
{ name: "jpg", value: "jpg" },
{ name: "jpeg", value: "jpeg" },
{ name: "gif", value: "gif" }
)
)
registry.registerChatInputCommand(
(builder) =>
builder
.setName(this.name)
.setDescription(this.description)
.addUserOption((option) =>
option
.setName("user")
.setDescription("the user to show the avatar of")
.setRequired(false)
)
.addNumberOption((option) =>
option
.setName("size")
.setDescription("the size of the avatar")
.setRequired(false)
.setChoices(
{ name: "16", value: 16 },
{ name: "32", value: 32 },
{ name: "64", value: 64 },
{ name: "128", value: 128 },
{ name: "256", value: 256 },
{ name: "512", value: 512 },
{ name: "1024", value: 1024 },
{ name: "2048", value: 2048 },
{ name: "4096", value: 4096 }
)
)
.addStringOption((option) =>
option
.setName("format")
.setDescription("the format of the avatar")
.setRequired(false)
.setChoices(
{ name: "webp", value: "webp" },
{ name: "png", value: "png" },
{ name: "jpg", value: "jpg" },
{ name: "jpeg", value: "jpeg" },
{ name: "gif", value: "gif" }
)
),
{ idHints: ["1171494645918875718"] }
);
}

Expand Down
80 changes: 80 additions & 0 deletions src/commands/misc/iplookup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { Command } from "@sapphire/framework";
import { fetch, FetchResultTypes } from "@sapphire/fetch";
import { EmbedBuilder } from "discord.js";

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) =>
builder
.setName(this.name)
.setDescription(this.description)
.addStringOption((option) =>
option
.setName("ip")
.setDescription("The ip address to lookup")
.setRequired(true)
),
{ idHints: ["1261706053960204351"] }
);
}

public override async chatInputRun(
interaction: Command.ChatInputCommandInteraction
) {
const ip = interaction.options.getString("ip", true);

if (
!ip.match(
"((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])"
) &&
!ip.match(
"(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))"
)
) {
return interaction.reply("Invalid ip address");
}

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

if (res.status !== "success") {
return interaction.reply("Failed to lookup ip address");
}

const embed = new EmbedBuilder().setTitle("IP Lookup").addFields([
{
name: "IP Address",
value: `\`${res.query}\``,
},
{
name: "Country",
value: `\`${res.country}\` (\`${res.countryCode}\`)`,
},
{
name: "City",
value: `\`${res.city}\``,
},
{
name: "ISP",
value: `\`${res.isp}\``,
},
{
name: "VPN/TOR",
value: `\`${res.proxy}\``,
},
]);

return interaction.reply({ embeds: [embed] });
}
}
24 changes: 24 additions & 0 deletions src/commands/misc/ping.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Command } from "@sapphire/framework";

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),
{ idHints: ["1231947622739345450"] }
);
}

public override async chatInputRun(
interaction: Command.ChatInputCommandInteraction
) {
return interaction.reply(`\`${interaction.client.ws.ping}ms\``);
}
}
Loading

0 comments on commit 657a3ad

Please sign in to comment.