Skip to content

Commit

Permalink
fix: switch to double quotes and fix tsconfig.json
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklvh committed Dec 19, 2023
1 parent f2d3a2d commit 085e061
Show file tree
Hide file tree
Showing 40 changed files with 671 additions and 689 deletions.
4 changes: 0 additions & 4 deletions .prettierrc

This file was deleted.

9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Discord bot made in Sapphire, Discord.js and TypeScript",
"main": "./dist/index.js",
"scripts": {
"build": "tsc -b src",
"start": "tsc -b src && node ."
"build": "tsc src",
"start": "tsc src && node ."
},
"private": true,
"repository": {
Expand Down Expand Up @@ -40,8 +40,5 @@
"prisma": "^5.7.1",
"typescript": "^5.3.3"
},
"packageManager": "[email protected]",
"_moduleAliases": {
"@lib": "dist/lib"
}
"packageManager": "[email protected]"
}
30 changes: 15 additions & 15 deletions src/commands/fun/cat.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { Command } from '@sapphire/framework';
import { fetch, FetchResultTypes } from '@sapphire/fetch';
import { EmbedBuilder } from 'discord.js';
import type { APIPetResponse } from '#types/Util';
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from "@sapphire/framework";
import { fetch, FetchResultTypes } from "@sapphire/fetch";
import { EmbedBuilder } from "discord.js";
import type { APIPetResponse } from "#types/Util";
import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: 'cat',
description: 'shows a cat 😽',
name: "cat",
description: "shows a cat 😽",
})
export class CatCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder.setName(this.name).setDescription(this.description),
builder.setName(this.name).setDescription(this.description)
);
}

public override async chatInputRun(
interaction: Command.ChatInputCommandInteraction,
interaction: Command.ChatInputCommandInteraction
) {
const data = await fetch<APIPetResponse>(
'https://api.thecatapi.com/v1/images/search',
FetchResultTypes.JSON,
"https://api.thecatapi.com/v1/images/search",
FetchResultTypes.JSON
).catch((error) => this.container.logger.error(error));

const embed = new EmbedBuilder();
Expand All @@ -30,10 +30,10 @@ export class CatCommand extends Command {
embeds: [
embed
.setAuthor({
name: 'Something went wrong! 😿',
name: "Something went wrong! 😿",
iconURL: interaction.user.avatarURL()!,
})
.setColor('Red')
.setColor("Red")
.setDescription(`Couldn't fetch a cat 😿\nTry again later!`),
],
});
Expand All @@ -46,8 +46,8 @@ export class CatCommand extends Command {
iconURL: interaction.user.avatarURL()!,
})
.setImage(data[0].url)
.setColor('Blue')
.setFooter({ text: 'Powered by thecatapi.com' }),
.setColor("Blue")
.setFooter({ text: "Powered by thecatapi.com" }),
],
});
}
Expand Down
22 changes: 11 additions & 11 deletions src/commands/fun/coinflip.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import { Command } from '@sapphire/framework';
import { ApplyOptions } from '@sapphire/decorators';
import { EmbedBuilder } from 'discord.js';
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 🪙',
name: "coinflip",
description: "flip! shows heads or tails 🪙",
})
export class CoinflipCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder.setName(this.name).setDescription(this.description),
builder.setName(this.name).setDescription(this.description)
);
}

public override chatInputRun(
interaction: Command.ChatInputCommandInteraction,
interaction: Command.ChatInputCommandInteraction
) {
return interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor({
name: 'Flip! 🪙',
name: "Flip! 🪙",
iconURL: interaction.user.avatarURL()!,
})
.addFields([
{
name: 'Result',
value: `\`${Math.random() > 0.5 ? 'Heads' : 'Tails'}\``,
name: "Result",
value: `\`${Math.random() > 0.5 ? "Heads" : "Tails"}\``,
},
])
.setColor('Blue'),
.setColor("Blue"),
],
});
}
Expand Down
30 changes: 15 additions & 15 deletions src/commands/fun/dog.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { Command } from '@sapphire/framework';
import { fetch, FetchResultTypes } from '@sapphire/fetch';
import { EmbedBuilder } from 'discord.js';
import type { APIPetResponse } from '#types/Util';
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from "@sapphire/framework";
import { fetch, FetchResultTypes } from "@sapphire/fetch";
import { EmbedBuilder } from "discord.js";
import type { APIPetResponse } from "#types/Util";
import { ApplyOptions } from "@sapphire/decorators";

@ApplyOptions<Command.Options>({
name: 'dog',
description: 'shows a dog 🐶',
name: "dog",
description: "shows a dog 🐶",
})
export class DogCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder.setName(this.name).setDescription(this.description),
builder.setName(this.name).setDescription(this.description)
);
}

public override async chatInputRun(
interaction: Command.ChatInputCommandInteraction,
interaction: Command.ChatInputCommandInteraction
) {
const data = await fetch<APIPetResponse>(
'https://api.thedogapi.com/v1/images/search',
FetchResultTypes.JSON,
"https://api.thedogapi.com/v1/images/search",
FetchResultTypes.JSON
).catch((error) => this.container.logger.error(error));

const embed = new EmbedBuilder();
Expand All @@ -30,10 +30,10 @@ export class DogCommand extends Command {
embeds: [
embed
.setAuthor({
name: 'Something went wrong! 🐶',
name: "Something went wrong! 🐶",
iconURL: interaction.user.avatarURL()!,
})
.setColor('Red')
.setColor("Red")
.setDescription(`Couldn't fetch a dog 🐶\nTry again later!`),
],
});
Expand All @@ -46,8 +46,8 @@ export class DogCommand extends Command {
iconURL: interaction.user.avatarURL()!,
})
.setImage(data[0].url)
.setColor('Blue')
.setFooter({ text: 'Powered by thedogapi.com' }),
.setColor("Blue")
.setFooter({ text: "Powered by thedogapi.com" }),
],
});
}
Expand Down
28 changes: 14 additions & 14 deletions src/commands/fun/duck.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
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';
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";

@ApplyOptions<Command.Options>({
name: 'duck',
description: 'shows a duck 🦆',
name: "duck",
description: "shows a duck 🦆",
})
export class DuckCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder.setName(this.name).setDescription(this.description),
builder.setName(this.name).setDescription(this.description)
);
}

public override async chatInputRun(
interaction: Command.ChatInputCommandInteraction,
interaction: Command.ChatInputCommandInteraction
) {
const data = await fetch<APIPetInterface>(
'https://random-d.uk/api/v2/quack',
FetchResultTypes.JSON,
"https://random-d.uk/api/v2/quack",
FetchResultTypes.JSON
).catch((error) => this.container.logger.error(error));

const embed = new EmbedBuilder();
Expand All @@ -30,10 +30,10 @@ export class DuckCommand extends Command {
embeds: [
embed
.setAuthor({
name: 'Something went wrong! 🦆',
name: "Something went wrong! 🦆",
iconURL: interaction.user.avatarURL()!,
})
.setColor('Red')
.setColor("Red")
.setDescription(`Couldn't fetch a duck 🦆\nTry again later!`),
],
});
Expand All @@ -46,7 +46,7 @@ export class DuckCommand extends Command {
iconURL: interaction.user.avatarURL()!,
})
.setImage(data.url)
.setColor('Blue')
.setColor("Blue")
.setFooter({ text: data.message! }),
],
});
Expand Down
76 changes: 38 additions & 38 deletions src/commands/fun/rps.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Command } from '@sapphire/framework';
import { ApplyOptions } from '@sapphire/decorators';
import { EmbedBuilder } from 'discord.js';
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? 🤔',
name: "rps",
description: "will it be: rock, paper, or scissors? 🤔",
})
export class RockPaperScissorsCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
Expand All @@ -14,66 +14,66 @@ export class RockPaperScissorsCommand extends Command {
.setDescription(this.description)
.addStringOption((option) =>
option
.setName('choice')
.setDescription('your choice of rock, paper, or scissors')
.setName("choice")
.setDescription("your choice of rock, paper, or scissors")
.setRequired(true)
.setChoices(
{
name: 'Rock',
value: 'Rock',
name: "Rock",
value: "Rock",
},
{
name: 'Paper',
value: 'Paper',
name: "Paper",
value: "Paper",
},
{
name: 'Scissors',
value: 'Scissors',
},
),
),
name: "Scissors",
value: "Scissors",
}
)
)
);
}

public override chatInputRun(
interaction: Command.ChatInputCommandInteraction,
interaction: Command.ChatInputCommandInteraction
) {
const random = Math.random();
const choice = interaction.options.getString('choice', true);
let result: 'win' | 'lose' | 'tie' = 'tie';
const myChoice: 'Rock' | 'Paper' | 'Scissors' =
random > 0.66 ? 'Rock' : random > 0.33 ? 'Paper' : 'Scissors';
const choice = interaction.options.getString("choice", true);
let result: "win" | "lose" | "tie" = "tie";
const myChoice: "Rock" | "Paper" | "Scissors" =
random > 0.66 ? "Rock" : random > 0.33 ? "Paper" : "Scissors";

if (myChoice === choice) result = 'tie';
if (myChoice === 'Rock' && choice === 'Paper') result = 'win';
if (myChoice === 'Rock' && choice === 'Scissors') result = 'lose';
if (myChoice === 'Paper' && choice === 'Scissors') result = 'win';
if (myChoice === 'Paper' && choice === 'Rock') result = 'lose';
if (myChoice === 'Scissors' && choice === 'Rock') result = 'win';
if (myChoice === 'Scissors' && choice === 'Paper') result = 'lose';
if (myChoice === choice) result = "tie";
if (myChoice === "Rock" && choice === "Paper") result = "win";
if (myChoice === "Rock" && choice === "Scissors") result = "lose";
if (myChoice === "Paper" && choice === "Scissors") result = "win";
if (myChoice === "Paper" && choice === "Rock") result = "lose";
if (myChoice === "Scissors" && choice === "Rock") result = "win";
if (myChoice === "Scissors" && choice === "Paper") result = "lose";

return interaction.reply({
embeds: [
new EmbedBuilder()
.setAuthor({
name: 'Rock, Paper, Scissors! 🤔',
name: "Rock, Paper, Scissors! 🤔",
iconURL: interaction.user.avatarURL()!,
})
.addFields([
{ name: 'You picked', value: `\`${choice}\``, inline: true },
{ name: 'I picked', value: `\`${myChoice}\``, inline: true },
{ name: "You picked", value: `\`${choice}\``, inline: true },
{ name: "I picked", value: `\`${myChoice}\``, inline: true },
{
name: 'Result',
name: "Result",
value: `\`${
result === 'win'
? 'You won!'
: result === 'lose'
? 'You lost!'
: 'We tied!'
result === "win"
? "You won!"
: result === "lose"
? "You lost!"
: "We tied!"
}\``,
},
])
.setColor('Blue'),
.setColor("Blue"),
],
});
}
Expand Down
Loading

0 comments on commit 085e061

Please sign in to comment.