mirror of
https://github.com/ahmadk953/poixpixel-discord-bot.git
synced 2025-06-07 23:49:29 +00:00
Stuff
This commit is contained in:
parent
444c90872a
commit
7293076ce9
6 changed files with 321 additions and 25 deletions
|
@ -7,24 +7,71 @@ import * as c_discord_bot from "../config/discord-bot";
|
|||
export class DiscordBot extends l_discord.Bot {
|
||||
public static config: l_config.Config<config.Config_Interface>;
|
||||
public static discord_bot: l_discord.Bot;
|
||||
public static polling_interval: 50; // ms
|
||||
public static guild: l_discord.Guild;
|
||||
|
||||
static main(
|
||||
p_config: config.Config_Interface
|
||||
) {
|
||||
console.log("Running bot tasks")
|
||||
|
||||
console.log("-- Loading configuration");
|
||||
this.config = new l_config.Config(
|
||||
config.defaulted,
|
||||
p_config
|
||||
);
|
||||
|
||||
this.discord_bot = new l_discord.Bot(this.config.real.discord);
|
||||
console.log("Starting");
|
||||
this.discord_bot.running = true;
|
||||
console.log("READY")
|
||||
|
||||
setTimeout(() => {
|
||||
this.discord_bot.running = false;
|
||||
console.log("offline");
|
||||
}, 2000);
|
||||
try {
|
||||
console.log("-- Logging into bot API");
|
||||
this.discord_bot.running = true;
|
||||
} catch (error: any) {
|
||||
DiscordBot.error_stop(error);
|
||||
}
|
||||
|
||||
try {
|
||||
console.log("-- Fetching guild");
|
||||
this.guild = this.discord_bot.get_guild({
|
||||
id: this.config.real.discord.guild_id
|
||||
})[0];
|
||||
} catch (error: any) {
|
||||
DiscordBot.error_stop(error);
|
||||
}
|
||||
|
||||
try {
|
||||
const channel_id = "1043280866744488067";
|
||||
console.log("-- Fetching test channel");
|
||||
|
||||
const channel = this.guild.get_channel({
|
||||
id: channel_id
|
||||
})[0];
|
||||
|
||||
console.log(channel, this.guild);
|
||||
const msg = new l_discord.Message();
|
||||
msg.text = "HELLO TEXT";
|
||||
|
||||
const message_stream = channel.messages;
|
||||
|
||||
const embed = new l_discord.Embed();
|
||||
embed.title = "Hello";
|
||||
embed.description = "IDK";
|
||||
msg.embeds = [ embed ];
|
||||
|
||||
message_stream.push(msg);
|
||||
} catch (error: any) {
|
||||
DiscordBot.error_stop(error);
|
||||
}
|
||||
|
||||
|
||||
console.log("All tasks completed");
|
||||
}
|
||||
|
||||
static error_stop(error: Error) {
|
||||
console.error("Fatal Error: Failed to execute bot tasks");
|
||||
console.error(error);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue