Initial Commit
This commit is contained in:
117
index.ts
Normal file
117
index.ts
Normal file
@@ -0,0 +1,117 @@
|
||||
import { token } from "./config.json";
|
||||
import type { Interaction } from "discord.js";
|
||||
import { Client, Events, GatewayIntentBits, MessageFlags, Collection } from "discord.js";
|
||||
import type { SlashCommandBuilder } from "discord.js"
|
||||
|
||||
const BLITZCRANK_BANNER = `
|
||||
****++++++++++*+++
|
||||
**+*+******+********+******+*++*
|
||||
**** *+*+**+*+*+*++++++++++++++*+++++*++++***
|
||||
*=....... + **+*+*+++++++++++++++++++++++++++*++++++++++**
|
||||
............= +****+*+*+++++++++#%%#######%*++++++++++++++**+**+**
|
||||
*.....=@@@@+......+*+++++++++++##*#*++++++++++***%*+++++****++++++*+*++
|
||||
.... @@. ..@% .. ..*++++++++%***++=%=+=======+++++**@+++++++++*++++*++**+
|
||||
.....=@-...:@#.....+*+++++%***++====+====--==-====++**#+++++++++**+++**+*+*
|
||||
.........@@@@-....-*++++#****++==---%:::::-------===+**#++++*++++++++++++***+
|
||||
+.... +@. .........+++%***+++==--::==.::::::+##*-===+**%++++++++++++++++++*+++
|
||||
*.......: .......--:.=@***++++=-::::.*....:=+:...-*-==+***+++++++++**+++++****+*
|
||||
*.......=%:......*+++****+%==-=*+::..--....*-.....=+==++*#++++++++++++++**++++*+**
|
||||
*+ ......+++++++++#+++*-::::::*....#....*+....:+:==++**%++++++++++++++*++++++++*
|
||||
*+++++*+*++++*++++#++#-:.......+...-+...:.#**#=-===+++*#+++++++*++++*++++**+++*+*
|
||||
*++*+++*+*+++++++++#*=#::.......+.::.#::::-=========+++**+++++++++++++++++++*+++*++
|
||||
*+**+++++++++++++++*%*+=-........+-:::-#::---========+++#@=+++++++++++++++++++++++*+*
|
||||
****+++*+**+*+++++++*%**+++:....+#=-----%-----========++@+===+++++++++++++++*+*+*++***
|
||||
***+++++++++++++*++++@****-+#%%*:===----=*-===========%#*@%%%%%%%%%%#*+++++++++++++++**
|
||||
**+*++*++++++++++*++++%#***++++++=========%======#%*==#***%###*******#%%%%@*++++++++++*+*
|
||||
**+*+++++++*+++++*++++*@*****++++++========#==#+===----=+#%#****++++*****@####++++++*+*+*
|
||||
+***++++*++++++++++++++@@#****++++++=======##===---------.%#*@%*+++++++**%#+**#++++*++***
|
||||
*+*+*++++++++++++++++++==%@@#%@@+++++========%##:-----::%*##=#-::#*++++++*@=++#*#+++++++*++
|
||||
*+*+*++++++*++++++++++=%%%@%@#####+++=======-%####+:=**#**--::--=##++++++==++####%+++++++**
|
||||
***++++++++*+++++++++%%%@###%@#*#*%++=========@*#*##%#=-::--=++%+-#=+======+####**%++++*+*+
|
||||
*+*+++++++++++++++++%%%#########%@%%*++======+%@%*##+*-*===#+-=====%=@#===#######**%+++++*+
|
||||
*+*++++++++++++++++%%%####**********#%%%%%%#*+++*#%*#*+#*-:=========%::-*########*#++++++*+
|
||||
*+*++++*++++++++++*##%##*****************+++++++++*#*##@*-===========%*##########*#++++*+*+
|
||||
***+*++*+++*++++++%###*%*****++++++++++++++***####%*#*@*##:===========%###########+++++*+*+
|
||||
++***++++*++++++++%#%*****##*+++++++++++**###%%+=====:@*##%-=========+#%########*++++*+++++
|
||||
*+***++*+*+*++++++%#%%%#++**+++##+++++*####@===========:@###-======%%#%%######%++++++++****
|
||||
***+++*++++++++++##%%####%#*==+=++*####@==+#========----:@#%-=#%%##%*=%*#####+++++++*+*+*
|
||||
+***++*++++++++++##%%%########%%%%%%%*=====-%+-====----::-#%%%##%+-*+##+*#@++++++++++**+*
|
||||
*+*++++++*++++++#%%%%%#######%%@@@==========:*:---:::::#*%%%#+-#*##%%+:#++++++*++++*+*+*
|
||||
*++*+++*++++++++++%%%%######%%@@%@*=======---.*+::.-+*###*+**###%%+:=#*#++++*++++++***+
|
||||
+*++*+**++*++++++++%%%####%@@@@@@%%=====---::.+++**##+++=*%%%%*:-*****#%#*%#*++*++*+*
|
||||
++*+++++++*++++++++++@%%%@@@@@@@@%%-==--::.:#*%##+-++###%#*::#***#**%=:-#**%++++*+++
|
||||
**+++*+++++++++++++++++++%@@@@@@@@%%:-:.=**#%#%*+*###%#=::+*####*%#*=:#***#*+++**+
|
||||
*++***++*+++++++++++++++++++++*#%@%@-#*#%*+*=*%%#%#+::+*#######*%#**##***%+++*+**
|
||||
*++**+++*++++++++++++++++++++++%#%#%%**-+####%#=::+*####%#####*%*####**%+++++++
|
||||
+*+*+*+**+++*++*+++++++++++++*%#%#%*#%*%%#=:+*#####%***##**%#*@###*%*++++**
|
||||
***+*++++++*++++++++*+++++++++%#%#%%%#=-+###########*-::-+##%#%%%%+****++
|
||||
*+++++++++++++++++++++++++++++%%%%++############*%*=-#*###*@#%%%+**+*+
|
||||
*+++*+*+*++++++++++++++++++++#%#####%##################*%#*#%***+++
|
||||
++*+*+**+*+***++++*++++***++*%###%#*%%###%*##%%#####@%%%%***+**
|
||||
*+*++++*+++++++++++++++++++*%#%%+=:..:=+=%#%%%%%%%%%%*+*+*+
|
||||
+*++***++++++++++++++++++++%%#*#*#######%#%%%%%%#+**+*
|
||||
**+*******+++**++**++*++#%%#########%%#%%%**++*+
|
||||
++**+*++++*+*+++++++++@#######%%%#*++*****
|
||||
**+*+*****++********##**+*++*+**+
|
||||
+******************+
|
||||
|
||||
"FIRED UP AND READY TO SERVE!"
|
||||
`;
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
GatewayIntentBits.GuildMembers,
|
||||
GatewayIntentBits.MessageContent,
|
||||
],
|
||||
});
|
||||
|
||||
interface Command {
|
||||
data: SlashCommandBuilder,
|
||||
execute: (i: Interaction) => void
|
||||
};
|
||||
|
||||
// TODO(DWM): The original tutorial has this thing where you walk paths in a
|
||||
// certain folder and look for specially constructed JS objects and
|
||||
// dynamically constructs a set of commands that way. Fucking miss me with
|
||||
// that, a billion times more complicated than it needs to be.
|
||||
|
||||
import * as _pingCommand from './commands/calendar/ping.ts' ;
|
||||
const pingCommand = _pingCommand as Command;
|
||||
|
||||
const commands = new Collection<string, Command>();
|
||||
commands.set(pingCommand.data.name, pingCommand);
|
||||
|
||||
client.on(Events.InteractionCreate, async (interaction: Interaction) => {
|
||||
if (!interaction.isChatInputCommand()) {
|
||||
return;
|
||||
}
|
||||
console.log(interaction.commandName);
|
||||
const command = commands.get(interaction.commandName);
|
||||
if (!command) {
|
||||
console.error(`No matching command ${interaction.commandName}`);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await command.execute(interaction);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
if (interaction.replied || interaction.deferred) {
|
||||
await interaction.followUp({
|
||||
content: "There was an error while executing this command",
|
||||
flags: MessageFlags.Ephemeral,
|
||||
});
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
});
|
||||
|
||||
client.once(Events.ClientReady, (readyClient) => {
|
||||
for (const ln of BLITZCRANK_BANNER.split("\n")) {
|
||||
console.log(ln);
|
||||
}
|
||||
console.log(`Logged in as ${readyClient.user.tag}`);
|
||||
});
|
||||
|
||||
client.login(token);
|
||||
Reference in New Issue
Block a user