-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I think I fixed it by making CrystalClient have a static value in itself to throw around, but I need to test. Events reload, commands I haven't tested yet
- Loading branch information
1 parent
f675c58
commit 601a2ae
Showing
16 changed files
with
211 additions
and
181 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Debug Bot", | ||
"skipFiles": ["<node_internals>/**"], | ||
"program": "${workspaceFolder}/src/index.ts", | ||
"preLaunchTask": "npm: build", | ||
"sourceMaps": true, | ||
"outFiles": ["${workspaceFolder}/out/**/*.js"], | ||
"cwd": "${workspaceFolder}/out" | ||
} | ||
] | ||
} |
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,24 @@ | ||
{ | ||
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "npm", | ||
"script": "start", | ||
"isBackground": true, | ||
"problemMatcher": { | ||
"owner": "typescript", | ||
"pattern": "$tsc", | ||
"background": { | ||
"activeOnStart": true, | ||
"beginsPattern": { | ||
"regexp": "(.*?)" | ||
}, | ||
"endsPattern": { | ||
"regexp": "Build complete" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -1,38 +1,26 @@ | ||
import { SlashCommandBuilder, type ChatInputCommandInteraction } from "discord.js"; | ||
import { type Command } from "../../types/Command"; | ||
import type CrystalClient from "../../types/CrystalClient"; | ||
import { SlashCommandBuilder, type ChatInputCommandInteraction } from "discord.js" | ||
import { type Command } from "../../types/Command" | ||
import type CrystalClient from "../../types/CrystalClient" | ||
|
||
module.exports = { | ||
name: 'dm', | ||
name: "dm", | ||
data: new SlashCommandBuilder() | ||
.setName("dm") | ||
.setDescription("Send a direct message to someone using the bot.") | ||
.addUserOption((option) => | ||
option | ||
.setName('user') | ||
.setDescription('The user you want to message.') | ||
.setRequired(true)) | ||
.addStringOption((option) => | ||
option | ||
.setName('message') | ||
.setDescription("If you want to send a message type it here.") | ||
.setRequired(false)) | ||
.addStringOption((option) => | ||
option | ||
.setName('emojis') | ||
.setDescription('The emoji(s) you want to react with.') | ||
.setRequired(false)) | ||
.addAttachmentOption((option) => | ||
option | ||
.setName('attachment') | ||
.setDescription('The attachment you want to send.') | ||
.setRequired(false)) | ||
.addStringOption((option) => | ||
option | ||
.setName('message_id') | ||
.setDescription('The message id you want to use.') | ||
.setRequired(false)), | ||
execute: async function (interaction: ChatInputCommandInteraction, client: CrystalClient): Promise<void> { | ||
|
||
} | ||
.addUserOption(option => | ||
option.setName("user").setDescription("The user you want to message.").setRequired(true) | ||
) | ||
.addStringOption(option => | ||
option.setName("message").setDescription("If you want to send a message type it here.").setRequired(false) | ||
) | ||
.addStringOption(option => | ||
option.setName("emojis").setDescription("The emoji(s) you want to react with.").setRequired(false) | ||
) | ||
.addAttachmentOption(option => | ||
option.setName("attachment").setDescription("The attachment you want to send.").setRequired(false) | ||
) | ||
.addStringOption(option => | ||
option.setName("message_id").setDescription("The message id you want to use.").setRequired(false) | ||
), | ||
execute: async function (interaction: ChatInputCommandInteraction, client: CrystalClient): Promise<void> {}, | ||
} satisfies Command |
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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
import { SlashCommandBuilder, type ChatInputCommandInteraction } from "discord.js" | ||
import { type Command } from "../../types/Command" | ||
import type CrystalClient from "../../types/CrystalClient" | ||
|
||
module.exports = { | ||
name: "hello", | ||
data: new SlashCommandBuilder().setName("hello").setDescription("Say hello!"), | ||
execute: async function (interaction: ChatInputCommandInteraction, client: CrystalClient) { | ||
void await interaction.reply({ | ||
execute: async function (interaction: ChatInputCommandInteraction) { | ||
void (await interaction.reply({ | ||
content: "Hey there!", | ||
ephemeral: false, | ||
}) | ||
})) | ||
}, | ||
} satisfies Command |
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 |
---|---|---|
@@ -1,41 +1,37 @@ | ||
import { SlashCommandBuilder, type ChatInputCommandInteraction, type TextChannel } from "discord.js"; | ||
import { type Command } from "../../types/Command"; | ||
import type CrystalClient from "../../types/CrystalClient"; | ||
import { SlashCommandBuilder, type ChatInputCommandInteraction, type TextChannel } from "discord.js" | ||
import { type Command } from "../../types/Command" | ||
import type CrystalClient from "../../types/CrystalClient" | ||
|
||
module.exports = { | ||
name: 'message', | ||
name: "message", | ||
data: new SlashCommandBuilder() | ||
.setName("message") | ||
.setDescription("Send a message using the bot.") | ||
.addChannelOption((option) => | ||
option | ||
.setName('channel') | ||
.setDescription('The channel to send the message to.') | ||
.setRequired(true)) | ||
.addStringOption((option) => | ||
option | ||
.setName('message') | ||
.setDescription('The message you want to send.') | ||
.setRequired(true)), | ||
.addChannelOption(option => | ||
option.setName("channel").setDescription("The channel to send the message to.").setRequired(true) | ||
) | ||
.addStringOption(option => | ||
option.setName("message").setDescription("The message you want to send.").setRequired(true) | ||
), | ||
execute: async function (interaction: ChatInputCommandInteraction, client: CrystalClient) { | ||
const textChannel = interaction.options.getChannel('channel') as TextChannel | ||
const botMessage = interaction.options.getString('message') | ||
const textChannel = interaction.options.getChannel("channel") as TextChannel | ||
const botMessage = interaction.options.getString("message") | ||
|
||
try { | ||
if (botMessage !== null) { | ||
void await textChannel.send(botMessage) | ||
void await interaction.reply({ | ||
void (await textChannel.send(botMessage)) | ||
void (await interaction.reply({ | ||
content: "Your message was sent.", | ||
ephemeral: true | ||
}) | ||
ephemeral: true, | ||
})) | ||
} else { | ||
void await interaction.reply({ | ||
void (await interaction.reply({ | ||
content: "Your message could not get sent.", | ||
ephemeral: true | ||
}) | ||
ephemeral: true, | ||
})) | ||
} | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
} | ||
}, | ||
} satisfies Command |
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 |
---|---|---|
@@ -1,57 +1,56 @@ | ||
import { SlashCommandBuilder, type ChatInputCommandInteraction, type TextChannel } from "discord.js"; | ||
import { type Command } from "../../types/Command"; | ||
import type CrystalClient from "../../types/CrystalClient"; | ||
import { SlashCommandBuilder, type ChatInputCommandInteraction, type TextChannel } from "discord.js" | ||
import { type Command } from "../../types/Command" | ||
import type CrystalClient from "../../types/CrystalClient" | ||
|
||
module.exports = { | ||
name: 'pin', | ||
name: "pin", | ||
data: new SlashCommandBuilder() | ||
.setName("pin") | ||
.setDescription("pin a message using the bot.") | ||
.addChannelOption((option) => | ||
.addChannelOption(option => | ||
option.setName("channel").setDescription("The channel you want to pin a message in.").setRequired(true) | ||
) | ||
.addStringOption(option => | ||
option | ||
.setName('channel') | ||
.setDescription('The channel you want to pin a message in.') | ||
.setRequired(true)) | ||
.addStringOption((option) => | ||
option | ||
.setName('message_id') | ||
.setDescription('The message you want to pin to using a message id.') | ||
.setRequired(true)), | ||
.setName("message_id") | ||
.setDescription("The message you want to pin to using a message id.") | ||
.setRequired(true) | ||
), | ||
execute: async function (interaction: ChatInputCommandInteraction, client: CrystalClient) { | ||
const textChannel = interaction.options.getChannel('channel') as TextChannel | ||
const messageId = interaction.options.getString('message_id') | ||
const textChannel = interaction.options.getChannel("channel") as TextChannel | ||
const messageId = interaction.options.getString("message_id") | ||
|
||
try { | ||
if (messageId !== null) { | ||
const targetMessage = await textChannel.messages.fetch(messageId) | ||
|
||
void await targetMessage.pin() | ||
void await interaction.reply({ | ||
void (await targetMessage.pin()) | ||
void (await interaction.reply({ | ||
content: "Successfully pinned the message.", | ||
ephemeral: true | ||
}) | ||
ephemeral: true, | ||
})) | ||
} else { | ||
void await interaction.reply({ | ||
void (await interaction.reply({ | ||
content: "Unsuccessfully pinned the message.", | ||
ephemeral: true | ||
}) | ||
ephemeral: true, | ||
})) | ||
} | ||
} catch (error: any) { | ||
switch (true) { | ||
case error.message.includes('Unknown Message'): | ||
void await interaction.reply({ | ||
case error.message.includes("Unknown Message"): | ||
void (await interaction.reply({ | ||
content: "Unsuccessfully pinned the message: Invalid message id.", | ||
ephemeral: true | ||
}) | ||
ephemeral: true, | ||
})) | ||
break | ||
default: | ||
void await interaction.reply({ | ||
void (await interaction.reply({ | ||
content: "Unsuccessfully pinned the message.", | ||
ephemeral: true | ||
}) | ||
ephemeral: true, | ||
})) | ||
|
||
console.error(error) | ||
} | ||
} | ||
} | ||
}, | ||
} satisfies Command |
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 |
---|---|---|
@@ -1,73 +1,70 @@ | ||
import { SlashCommandBuilder, type ChatInputCommandInteraction, type TextChannel } from "discord.js"; | ||
import { type Command } from "../../types/Command"; | ||
import type CrystalClient from "../../types/CrystalClient"; | ||
import { SlashCommandBuilder, type ChatInputCommandInteraction, type TextChannel } from "discord.js" | ||
import { type Command } from "../../types/Command" | ||
import type CrystalClient from "../../types/CrystalClient" | ||
|
||
module.exports = { | ||
name: 'react', | ||
name: "react", | ||
data: new SlashCommandBuilder() | ||
.setName("react") | ||
.setDescription("React to a message using the bot.") | ||
.addChannelOption((option) => | ||
.addChannelOption(option => | ||
option.setName("channel").setDescription("The channel you want to react to.").setRequired(true) | ||
) | ||
.addStringOption(option => | ||
option | ||
.setName('channel') | ||
.setDescription('The channel you want to react to.') | ||
.setRequired(true)) | ||
.addStringOption((option) => | ||
option | ||
.setName('message_id') | ||
.setDescription('The message you want to react to using a message id.') | ||
.setRequired(true)) | ||
.addStringOption((option) => | ||
option | ||
.setName('emojis') | ||
.setDescription('The emoji(s) you want to react with.') | ||
.setRequired(true)), | ||
.setName("message_id") | ||
.setDescription("The message you want to react to using a message id.") | ||
.setRequired(true) | ||
) | ||
.addStringOption(option => | ||
option.setName("emojis").setDescription("The emoji(s) you want to react with.").setRequired(true) | ||
), | ||
execute: async function (interaction: ChatInputCommandInteraction, client: CrystalClient) { | ||
const textChannel = interaction.options.getChannel('channel') as TextChannel | ||
const messageId = interaction.options.getString('message_id') | ||
const emojis = interaction.options.getString('emojis') | ||
const textChannel = interaction.options.getChannel("channel") as TextChannel | ||
const messageId = interaction.options.getString("message_id") | ||
const emojis = interaction.options.getString("emojis") | ||
|
||
try { | ||
if ((emojis !== null) && (messageId !== null)) { | ||
if (emojis !== null && messageId !== null) { | ||
const targetMessage = await textChannel.messages.fetch(messageId) | ||
const emojiArray = emojis.split(' ') | ||
const emojiArray = emojis.split(" ") | ||
|
||
for (const emoji of emojiArray) { | ||
void await targetMessage.react(emoji.trim()) | ||
void (await targetMessage.react(emoji.trim())) | ||
} | ||
|
||
void await interaction.reply({ | ||
void (await interaction.reply({ | ||
content: "The reaction was successful.", | ||
ephemeral: true | ||
}) | ||
ephemeral: true, | ||
})) | ||
} else { | ||
void await interaction.reply({ | ||
void (await interaction.reply({ | ||
content: "The reaction failed.", | ||
ephemeral: true | ||
}) | ||
ephemeral: true, | ||
})) | ||
} | ||
} catch (error: any) { | ||
switch (true) { | ||
case error.message.includes('Unknown Message'): | ||
void await interaction.reply({ | ||
case error.message.includes("Unknown Message"): | ||
void (await interaction.reply({ | ||
content: "The reaction failed: Invalid message id.", | ||
ephemeral: true | ||
}) | ||
ephemeral: true, | ||
})) | ||
break | ||
case error.message.includes('Unknown Emoji'): | ||
void await interaction.reply({ | ||
case error.message.includes("Unknown Emoji"): | ||
void (await interaction.reply({ | ||
content: "The reaction failed: Invalid emoji(s).", | ||
ephemeral: true | ||
}) | ||
ephemeral: true, | ||
})) | ||
break | ||
default: | ||
void await interaction.reply({ | ||
void (await interaction.reply({ | ||
content: "The reaction failed.", | ||
ephemeral: true | ||
}) | ||
ephemeral: true, | ||
})) | ||
|
||
console.error(error) | ||
} | ||
} | ||
} | ||
}, | ||
} satisfies Command |
Oops, something went wrong.