bug fixes/remove tweet channel

This commit is contained in:
SowinskiBraeden committed 2022-07-03 19:12:09 -07:00
1 parent 918b383a48
commit 9d9c23e8cc
6 files changed
+137 -50

No files matched your search

+1 -9
View File
@@ -8,14 +8,6 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
SlashCommand: {
options: [
{
@@ -28,7 +20,7 @@ module.exports = {
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
+1 -8
View File
@@ -8,13 +8,6 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
SlashCommand: {
options: [
{
@@ -27,7 +20,7 @@ module.exports = {
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
+61
View File
@@ -0,0 +1,61 @@
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
module.exports = {
name: "removetweetchannel",
description: "Remove tweet channel",
usage: "",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["MANAGE_GUILD"],
},
SlashCommand: {
options: [],
/**
*
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send(`You are not allowed to use the bot in this channel.`);
}
let message = new MessageEmbed()
.setTitle('Are you sure you want to stop using this channel for tweets?')
.setColor(client.config.EmbedColor)
let row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`yes`)
.setLabel("Yes")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`no`)
.setLabel("No")
.setStyle("SUCCESS")
)
interaction.send({ embeds: [message], components: [row] });
client.once("interactionCreate", ButtonInteraction => {
if (ButtonInteraction.message.interaction &&
ButtonInteraction.message.interaction.commandName!='removetweetchannel') return;
let queryString = ButtonInteraction.customId;
let action = ''
if (queryString=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.tweetChannel":null}},function(err, res) {
if (err) throw err;
});
} else if (queryString=='no') {
action = 'kept';
}
return ButtonInteraction.update({ content: `Successfully ${action} channel.`, embeds: [], components: [] });
});
return;
},
},
}
+46
View File
@@ -0,0 +1,46 @@
const { MessageEmbed } = require('discord.js');
module.exports = {
name: "settweetchannel",
description: "Select a channel to send tweets",
usage: "[channel]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["MANAGE_GUILD"],
},
SlashCommand: {
options: [
{
name: "channel",
description: "Channel to add to allowed channles",
value: "channel",
type: 7,
required: true,
},
],
/**
*
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send(`You are not allowed to use the bot in this channel.`);
}
let channelid = args[0].value;
let channel = client.channels.cache.get(channelid);
if (!channel) return interaction.send(`Cannot find that channel.`);
if (channel.type=="voice") return interaction.send(`Connot set voice channel to preferred channel.`);
if (channel.deleted) return interaction.send(`Connot set deleted channel to preferred channel.`);
let guild = await client.dbo.collection("guilds").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
if (client.exists(guild.server.tweetChannel)&&guild.server.tweetChannel==channelid) return interaction.send(`The channel <#${args[0].value}> has already been set for tweets.`);
client.dbo.collection("guilds").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.tweetChannel":channelid}},function(err, res) {
if (err) throw err;
return interaction.send(`Successfully set <#${args[0].value}> for tweets.`);
});
},
},
}
+1 -8
View File
@@ -8,13 +8,6 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
SlashCommand: {
options: [
{
@@ -27,7 +20,7 @@ module.exports = {
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
+27 -25
View File
@@ -27,32 +27,34 @@ class QuarksBot extends Client {
this.Ready = false;
this.ws.on("INTERACTION_CREATE", async (interaction) => {
client.log("Interaction")
let GuildDB = await this.GetGuild(interaction.guild_id);
const command = interaction.data.name.toLowerCase();
const args = interaction.data.options;
if (interaction.type!=3) {
client.log("Interaction")
let GuildDB = await this.GetGuild(interaction.guild_id);
//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,
},
});
};
let cmd = client.commands.get(command);
if (cmd.SlashCommand && cmd.SlashCommand.run)
cmd.SlashCommand.run(this, interaction, args, { GuildDB });
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,
},
});
};
let cmd = client.commands.get(command);
if (cmd.SlashCommand && cmd.SlashCommand.run)
cmd.SlashCommand.run(this, interaction, args, { GuildDB });
}
});
const client = this;