fix deprecation issues
This commit is contained in:
31 files changed
+586
-1933
No files matched your search
@@ -1,5 +1,6 @@
|
||||
const { Collection, Client, MessageEmbed } = require('discord.js');
|
||||
const { Collection, Client, EmbedBuilder, Routes } = require('discord.js');
|
||||
const MongoClient = require('mongodb').MongoClient;
|
||||
const { REST } = require('@discordjs/rest');
|
||||
const Logger = require("../util/Logger");
|
||||
const io = require('socket.io-client');
|
||||
const path = require("path");
|
||||
@@ -28,38 +29,42 @@ class LinesPoliceCadBot extends Client {
|
||||
this.Ready = false;
|
||||
|
||||
this.ws.on("INTERACTION_CREATE", async (interaction) => {
|
||||
let GuildDB = await this.GetGuild(interaction.guild_id);
|
||||
|
||||
if (interaction.type==3) return;
|
||||
|
||||
const command = interaction.data.name.toLowerCase();
|
||||
const args = interaction.data.options;
|
||||
|
||||
//Easy to send respnose so ;)
|
||||
interaction.guild = await this.guilds.fetch(interaction.guild_id);
|
||||
interaction.send = async (message) => {
|
||||
return await this.api
|
||||
.interactions(interaction.id, interaction.token)
|
||||
.callback.post({
|
||||
data: {
|
||||
type: 4,
|
||||
data:
|
||||
typeof message == "string"
|
||||
? { content: message }
|
||||
: message.type && message.type === "rich"
|
||||
? { embeds: [message] }
|
||||
: message,
|
||||
},
|
||||
const start = new Date().getTime();
|
||||
if (interaction.type!=3) {
|
||||
client.log("Interaction")
|
||||
let GuildDB = await this.GetGuild(interaction.guild_id);
|
||||
|
||||
const command = interaction.data.name.toLowerCase();
|
||||
const args = interaction.data.options;
|
||||
|
||||
//Easy to send respnose so ;)
|
||||
interaction.guild = await this.guilds.fetch(interaction.guild_id);
|
||||
interaction.send = async (message) => {
|
||||
const rest = new REST({ version: '10' }).setToken(client.config.Token);
|
||||
|
||||
return await rest.post(Routes.interactionCallback(interaction.id, interaction.token), {
|
||||
body: {
|
||||
type: 4,
|
||||
data: message,
|
||||
}
|
||||
});
|
||||
};
|
||||
let cmd = client.commands.get(command);
|
||||
client.log("Interaction - "+cmd.name);
|
||||
if (cmd.SlashCommand && cmd.SlashCommand.run)
|
||||
cmd.SlashCommand.run(this, interaction, args, { GuildDB });
|
||||
});
|
||||
try {
|
||||
cmd.SlashCommand.run(this, interaction, args, { GuildDB }, start); // start is only used in ping / stats command
|
||||
} catch (err) {
|
||||
client.error(err)
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
const client = this;
|
||||
}
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const client = this;
|
||||
}
|
||||
|
||||
async connectMongo(mongoURI, dbo) {
|
||||
this.db = await MongoClient.connect(mongoURI,{useUnifiedTopology:true});
|
||||
@@ -151,7 +156,7 @@ class LinesPoliceCadBot extends Client {
|
||||
}
|
||||
|
||||
sendTime(Channel, Error) {
|
||||
let embed = new MessageEmbed()
|
||||
let embed = new EmbedBuilder()
|
||||
.setColor(this.config.EmbedColor)
|
||||
.setDescription(Error);
|
||||
|
||||
@@ -228,7 +233,7 @@ class LinesPoliceCadBot extends Client {
|
||||
}
|
||||
|
||||
sendError(Channel, Error) {
|
||||
let embed = new MessageEmbed()
|
||||
let embed = new EmbedBuilder()
|
||||
.setTitle("An error occured")
|
||||
.setColor("RED")
|
||||
.setDescription(Error)
|
||||
|
||||
Reference in new issue
Block a user