Skip to content

Commit

Permalink
style: reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
tinarskii committed Nov 6, 2022
1 parent f9a83bf commit aa4d302
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 13 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ However, here are some of the features that will be implemented:
- [ ] Moderation commands
- [x] Fun commands
- [ ] Utility commands
- [ ] Game commands
- [ ] Search commands
- [ ] Music commands
- [x] NSFW commands
- [ ] Economy system
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
"discordx": "^11.4.0",
"dotenv": "^16.0.3",
"eslint": "8.22",
"ms": "^2.1.3",
"prisma": "^4.5.0",
"typescript": "^4.8.4"
},
"devDependencies": {
"@types/ms": "^0.7.31",
"concurrently": "^7.5.0"
}
}
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

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

12 changes: 7 additions & 5 deletions src/commands/game/8ball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export class Magic8Ball {
type: ApplicationCommandOptionType.String,
required: true,
})
question: string,
interaction: CommandInteraction,
question: string,
interaction: CommandInteraction,
): Promise<void> {
const answers = [
"Signs point to yes.",
Expand All @@ -33,10 +33,12 @@ export class Magic8Ball {
await interaction.reply({
embeds: [
new EmbedBuilder()
.setTitle("Magic 8 Ball")
.setDescription(`**Question:** ${question}\n**Answer:** ${answers[Math.floor(Math.random() * answers.length)]}`)
.setTitle("🔮Magic 8 Ball")
.setDescription(
`**Question:** ${question}\n**Answer:** ${answers[Math.floor(Math.random() * answers.length)]}`,
)
.setColor(Colors.Blue),
],
});
}
}
}
34 changes: 34 additions & 0 deletions src/commands/game/bet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Discord, Slash, SlashOption } from "discordx";
import { Category } from "@discordx/utilities";
import { ApplicationCommandOptionType } from "discord-api-types/v10";
import { CommandInteraction } from "discord.js";

@Discord()
@Category("Game")
export class BetCommand {
@Slash({ description: "Bet on a number between 1 and 10", name: "bet" })
async bet(
@SlashOption({
name: "number",
description: "Number to bet on",
type: ApplicationCommandOptionType.Number,
required: true,
})
@SlashOption({
name: "amount",
description: "Amount of money to bet on",
type: ApplicationCommandOptionType.Number,
required: true,
})
number: number,
amount: number,
interaction: CommandInteraction,
): Promise<void> {
const random = Math.floor(Math.random() * 10) + 1;
if (number === random) {
await interaction.reply(`You won! The number was ${random}\nYou won ${Math.ceil(amount * 1.3)} coins`);
} else {
await interaction.reply(`You lost! The number was ${random}\nYou lost ${amount} coins`);
}
}
}
39 changes: 39 additions & 0 deletions src/commands/game/coin-flip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Discord, Slash, SlashOption } from "discordx";
import { Category } from "@discordx/utilities";
import { ApplicationCommandOptionType, CommandInteraction, EmbedBuilder } from "discord.js";

@Discord()
@Category("Game")
export class CoinFlipCommand {
@Slash({ description: "Flip a coin", name: "coin-flip" })
async coinFlip(
@SlashOption({
name: "seed",
description: "Seed for RNG",
type: ApplicationCommandOptionType.Integer,
required: false,
})
seed: number = new Date().getTime(),
interaction: CommandInteraction,
): Promise<void> {
const randomNum = (seedVal: number) => {
let seed = seedVal;
const rn = Math.sin(seed++) * 10000;
return rn - Math.floor(rn);
};
const genNum = randomNum(seed) * 100;
const isEven = Math.trunc(genNum) % 2 === 0;
await interaction.reply({
embeds: [
new EmbedBuilder()
.setTitle("🎲 Coin Flip")
.addFields([
{ name: "Result", value: isEven ? "Heads" : "Tails" },
{ name: "Generated Number", value: String(genNum) },
{ name: "Seed", value: String(seed) },
])
.setColor([0, 255, 0]),
],
});
}
}
68 changes: 68 additions & 0 deletions src/commands/misc/bot-stats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { Category } from "@discordx/utilities";
import { Discord, Slash, SlashGroup } from "discordx";
import { Colors, CommandInteraction, EmbedBuilder } from "discord.js";
import ms from "ms";
import os from "os";
import { version } from "discord.js";
import { bot } from "../../index.js";

@Discord()
@Category("Miscellaneous")
@SlashGroup({ description: "Get bot stats", name: "bot-stats" })
@SlashGroup("bot-stats")
export class BotStatsCommand {
@Slash({ description: "Get bot server stats", name: "server" })
async server(interaction: CommandInteraction): Promise<void> {
await interaction.reply({
embeds: [
new EmbedBuilder()
.setTitle("Bot server info")
.setThumbnail(bot.user!.displayAvatarURL())
.addFields([
{ name: "Platform", value: `${os.platform()} ${os.release()}`, inline: true },
{ name: "Architecture", value: os.arch(), inline: true },
{ name: "System Uptime", value: ms(ms(`${os.uptime()}s`)), inline: true },
{ name: "System Hostname", value: os.hostname(), inline: true },
{ name: "CPUs", value: [...new Set(os.cpus().map((x) => x.model))].join("\n"), inline: true },
{ name: "CPU Cores", value: os.cpus().length.toString(), inline: true },
{ name: "RAM Free", value: `${(os.freemem() / 1024 / 1024).toFixed(2)} MB`, inline: true },
{ name: "RAM Total", value: `${(os.totalmem() / 1024 / 1024).toFixed(2)} MB`, inline: true },
{ name: "RAM Usage", value: `${((1 - os.freemem() / os.totalmem()) * 100).toFixed(2)}%`, inline: true },
{ name: "Discord.js Version", value: `v${version}`, inline: true },
{ name: "Node.js Version", value: process.version, inline: true },
{ name: "Bots Version", value: "0.0.1", inline: true },
])
.setColor([0, 153, 255])
.setFooter({
text: `Requested by ${interaction.user.tag}`,
iconURL: interaction.user.avatarURL()!,
}),
],
});
}

@Slash({ description: "Get bot user stats", name: "user" })
async user(interaction: CommandInteraction): Promise<void> {
await interaction.reply({
embeds: [
new EmbedBuilder()
.setTitle("Bot info")
.setColor(Colors.Blue)
.setDescription(
`
**Servers:** ${bot.guilds.cache.size}
**Members:** ${bot.guilds.cache.reduce((a, g) => a + g.memberCount, 0)}
**Channels:** ${bot.channels.cache.size}
**Commands:** ${bot.application?.commands.cache.size}
**Uptime:** ${ms(bot.uptime!)}
`,
)
.setThumbnail(bot.user!.displayAvatarURL())
.setFooter({
text: `Requested by ${interaction.user.tag}`,
iconURL: interaction.user.avatarURL()!,
}),
],
});
}
}
74 changes: 74 additions & 0 deletions src/commands/misc/info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { Discord, Slash, SlashGroup, SlashOption } from "discordx";
import { Category } from "@discordx/utilities";
import { ApplicationCommandOptionType, Colors, CommandInteraction, EmbedBuilder, GuildMember, User } from "discord.js";

@Discord()
@Category("Miscellaneous")
@SlashGroup({
description: "Get user info or server info",
name: "info",
})
@SlashGroup("info")
export class InfoCommand {
@Slash({ description: "Get user info", name: "user" })
async user(
@SlashOption({
description: "User to get info",
name: "user",
type: ApplicationCommandOptionType.User,
required: true,
})
member: GuildMember,
interaction: CommandInteraction,
): Promise<void> {
await interaction.reply({
embeds: [
new EmbedBuilder()
.setTitle(`🙍‍♂ User ${member.user.username}`)
.addFields([
{ name: "💳 Username", value: member.user.username, inline: true },
{ name: "✏ Nickname", value: member.nickname ? member.nickname : "No nickname", inline: true },
{ name: "🆔 UserID", value: member.user.id.toString(), inline: true },
{ name: "#️⃣ Discriminator", value: member.user.discriminator, inline: true },
{
name: "🕐 Joined Discord",
value: `<t:${Math.trunc(member.user.createdTimestamp / 1000)}:R>`,
inline: true,
},
{
name: "👋 Joined Server",
value: `<t:${Math.trunc(member.joinedTimestamp! / 1000)}:R>`,
inline: true,
},
])
.setThumbnail(member.user.avatarURL())
.setColor(Colors.Blurple)
.setImage(member.user.banner ?? "https://i.redd.it/pyeuy7iyfw961.png"),
],
});
}

@Slash({ description: "Get server info", name: "server" })
async server(interaction: CommandInteraction): Promise<void> {
const server = await interaction.guild!;

await interaction.reply({
embeds: [
new EmbedBuilder()
.setTitle(`🚀 Server ${server.name}`)
.setColor(Colors.Blurple)
.addFields([
{ name: "👋 Server name", value: server.name, inline: true },
{ name: "📃 Server ID", value: server.id.toString(), inline: true },
{ name: "🙍‍♂️ Server Owner", value: `<@${server.ownerId}>`, inline: true },
{ name: "👪 All member", value: `${server.memberCount} members`, inline: true },
{ name: "🚫 NSFW Level", value: server.nsfwLevel.toString(), inline: true },
{ name: "👮‍♀️ Verification level", value: server.verificationLevel.toString(), inline: true },
{ name: "✅ isVerified", value: server.verified.toString(), inline: true },
{ name: "🚨 mfaLevel", value: server.mfaLevel.toString(), inline: true },
])
.setThumbnail(<string>server.iconURL()),
],
});
}
}
8 changes: 5 additions & 3 deletions src/commands/nsfw/danbooru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export class DanbooruCommand {
await interaction.reply("This channel is not Age-Restricted!");
return;
}

const { data } = await axios.get(`https://danbooru.donmai.us/posts.json?tags=${tags}&page=${Math.floor(Math.random() * 100) + 1}&limit=1`);

const { data } = await axios.get(
`https://danbooru.donmai.us/posts.json?tags=${tags}&page=${Math.floor(Math.random() * 100) + 1}&limit=1`,
);
await interaction.reply({
embeds: [
new EmbedBuilder()
Expand All @@ -43,4 +45,4 @@ export class DanbooruCommand {
],
});
}
}
}
10 changes: 7 additions & 3 deletions src/commands/nsfw/gelbooru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ export class GelbooruCommand {
await interaction.reply("This channel is not Age-Restricted!");
return;
}

const { data } = await axios.get(`https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&limit=1&pid=${Math.floor(Math.random() * 100) + 1}&tags=${tags.split(",").join("+")}`);

const { data } = await axios.get(
`https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&limit=1&pid=${
Math.floor(Math.random() * 100) + 1
}&tags=${tags.split(",").join("+")}`,
);

if (!data.post) {
await interaction.reply("No results found!");
Expand All @@ -40,4 +44,4 @@ export class GelbooruCommand {
],
});
}
}
}
4 changes: 2 additions & 2 deletions src/commands/nsfw/rule34.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class Rule34Command {
await interaction.reply("This channel is not Age-Restricted!");
return;
}

const { data } = await axios.get(`https://rule34.xxx/index.php?page=dapi&s=post&q=index&tags=${tags}&json=1`);
const image = data[Math.floor(Math.random() * data.length)];

Expand All @@ -36,4 +36,4 @@ export class Rule34Command {
],
});
}
}
}

0 comments on commit aa4d302

Please sign in to comment.