edit fact embed
This commit is contained in:
parent
858343d7b0
commit
48c255ae8e
12
src/bot.ts
12
src/bot.ts
|
@ -23,14 +23,14 @@ import {pagination} from "@devraelfreeze/discordjs-pagination";
|
||||||
export class Bot {
|
export class Bot {
|
||||||
public axiosClient;
|
public axiosClient;
|
||||||
private static instance: Bot;
|
private static instance: Bot;
|
||||||
|
public client: Client;
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
const client = new Client({intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]});
|
this.client = new Client({intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]});
|
||||||
this.axiosClient = axios.create({
|
this.axiosClient = axios.create({
|
||||||
baseURL: config.apiUrl,
|
baseURL: config.apiUrl,
|
||||||
});
|
});
|
||||||
this.axiosClient.defaults.headers.common['x-api-key'] = config.apiKey;
|
this.axiosClient.defaults.headers.common['x-api-key'] = config.apiKey;
|
||||||
|
|
||||||
this.registerCommands();
|
this.registerCommands();
|
||||||
const commands: Collection<any, any> = new Collection();
|
const commands: Collection<any, any> = new Collection();
|
||||||
commands.set(Fact.data.name, Fact);
|
commands.set(Fact.data.name, Fact);
|
||||||
|
@ -41,15 +41,15 @@ export class Bot {
|
||||||
commands.set(Facts.data.name, Facts);
|
commands.set(Facts.data.name, Facts);
|
||||||
|
|
||||||
|
|
||||||
client.once(Events.ClientReady, readyClient => {
|
this.client.once(Events.ClientReady, readyClient => {
|
||||||
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
|
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on(Events.Error, (err) => {
|
this.client.on(Events.Error, (err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on(Events.InteractionCreate, async interaction => {
|
this.client.on(Events.InteractionCreate, async interaction => {
|
||||||
if (!interaction.isChatInputCommand()) return;
|
if (!interaction.isChatInputCommand()) return;
|
||||||
const command = commands.get(interaction.commandName);
|
const command = commands.get(interaction.commandName);
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ export class Bot {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.login(config.token);
|
this.client.login(config.token);
|
||||||
}
|
}
|
||||||
|
|
||||||
private registerCommands() {
|
private registerCommands() {
|
||||||
|
|
|
@ -23,8 +23,16 @@ export default {
|
||||||
const fact = response.data.fact;
|
const fact = response.data.fact;
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle('Random Fact')
|
.setTitle('Random Fact')
|
||||||
|
.setAuthor({
|
||||||
|
name: 'Beaver Facts',
|
||||||
|
iconURL: bot.client.emojis.cache.get('1237383875924197456').imageURL(),
|
||||||
|
})
|
||||||
.setDescription(fact.content)
|
.setDescription(fact.content)
|
||||||
.setURL(fact.source)
|
.setURL(fact.source)
|
||||||
|
.setFooter({
|
||||||
|
text: 'ID: ' + fact.id + ' | Counter: ' + fact.counter,
|
||||||
|
iconURL: interaction.guild.iconURL(),
|
||||||
|
})
|
||||||
.setColor(0xffe600);
|
.setColor(0xffe600);
|
||||||
|
|
||||||
console.log('Sent beaver fact with id: ' + fact.id);
|
console.log('Sent beaver fact with id: ' + fact.id);
|
||||||
|
|
Loading…
Reference in New Issue