-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
252 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]), | ||
], | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()!, | ||
}), | ||
], | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()), | ||
], | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters