Suggestions and guide now work in DMs. Invite no longer has the bot scope (no longer required by discord)
diff --git a/src/commands/nucleus/guide.ts b/src/commands/nucleus/guide.ts
index c95e78c..8c32ef6 100644
--- a/src/commands/nucleus/guide.ts
+++ b/src/commands/nucleus/guide.ts
@@ -6,7 +6,7 @@
builder.setName("guide").setDescription("Shows the welcome guide for the bot");
const callback = async (interaction: CommandInteraction) => {
- await guide(interaction.guild!, interaction);
+ await guide(interaction.guild, interaction);
};
export { command };
diff --git a/src/commands/nucleus/invite.ts b/src/commands/nucleus/invite.ts
index 0307c68..561de03 100644
--- a/src/commands/nucleus/invite.ts
+++ b/src/commands/nucleus/invite.ts
@@ -23,7 +23,7 @@
.setURL(
`https://discord.com/api/oauth2/authorize?client_id=${
client.user!.id
- }&permissions=407900777662&scope=bot%20applications.commands`
+ }&permissions=407900777662&scope=applications.commands`
)
])
],
diff --git a/src/commands/nucleus/suggest.ts b/src/commands/nucleus/suggest.ts
index c1f0312..f6755e2 100644
--- a/src/commands/nucleus/suggest.ts
+++ b/src/commands/nucleus/suggest.ts
@@ -19,7 +19,6 @@
builder.setName("suggest").setDescription("Sends a suggestion to the developers");
const callback = async (interaction: CommandInteraction): Promise<void> => {
- await interaction.guild?.members.fetch(interaction.member!.user.id);
await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
let closed = false;
let suggestionTitle: string | null = null;
@@ -90,18 +89,25 @@
suggestionTitle = suggestionTitle ? suggestionTitle : `${suggestionDesc.substring(0, 70)}`;
const channel = client.channels.cache.get(config.suggestionChannel) as Discord.TextChannel;
const m = await channel.send({ embeds: LoadingEmbed });
- const issue = await client.GitHub.rest.issues.create({
- owner: "ClicksMinutePer",
- repo: "Nucleus",
- title: suggestionTitle,
- body: `Linked Suggestion in Private Developer Channel: [Message](${
- m.url
- })\n\n**Suggestion:**\n> ${suggestionDesc
- .replaceAll("@", "@<!-- -->")
- .replaceAll("/issues", "/issues<!-- -->")
- .replaceAll("/pull", "/pull<!-- -->")}\n\n`,
- labels: ["🤖 Auto", "📝 Suggestion"]
- });
+ let issueNumber: number | null = null;
+ try {
+ const issue = await client.GitHub.rest.issues.create({
+ owner: "ClicksMinutePer",
+ repo: "Nucleus",
+ title: suggestionTitle,
+ body: `Linked Suggestion in Private Developer Channel: [Message](${
+ m.url
+ })\n\n**Suggestion:**\n> ${suggestionDesc
+ .replaceAll("@", "@<!-- -->")
+ .replaceAll("/issues", "/issues<!-- -->")
+ .replaceAll("/pull", "/pull<!-- -->")}\n\n`,
+ labels: ["🤖 Auto", "📝 Suggestion"]
+ });
+ issueNumber = issue.data.number;
+ } catch (_e) {
+ console.log("Could not connect to GitHub");
+ }
+ const disabled = issueNumber ? false : true;
await m.edit({
embeds: [
new EmojiEmbed()
@@ -109,25 +115,27 @@
.setTitle(`Suggestion from ${interaction.user.tag} (${interaction.user.id})`)
.setDescription(`**Suggestion:**\n> ${suggestionDesc}\n\n`)
.setStatus("Success")
- .setFooter({ text: `${issue.data.number}` })
+ .setFooter({ text: `${issueNumber ? issueNumber : "Could not connect to GitHub"}` })
],
components: [
new Discord.ActionRowBuilder<ButtonBuilder>().addComponents(
- new ButtonBuilder().setCustomId("accept:Suggestion").setLabel("Accept").setStyle(ButtonStyle.Success),
- new ButtonBuilder().setCustomId("deny:Suggestion").setLabel("Deny").setStyle(ButtonStyle.Danger),
- new ButtonBuilder().setCustomId("close:Suggestion").setLabel("Close").setStyle(ButtonStyle.Secondary),
+ new ButtonBuilder().setCustomId("accept:Suggestion").setLabel("Accept").setStyle(ButtonStyle.Success).setDisabled(disabled),
+ new ButtonBuilder().setCustomId("deny:Suggestion").setLabel("Deny").setStyle(ButtonStyle.Danger).setDisabled(disabled),
+ new ButtonBuilder().setCustomId("close:Suggestion").setLabel("Close").setStyle(ButtonStyle.Secondary).setDisabled(disabled),
new ButtonBuilder()
.setCustomId("implemented:Suggestion")
.setLabel("Implemented")
- .setStyle(ButtonStyle.Secondary),
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(disabled),
new ButtonBuilder()
- .setLabel(`Open Issue #${issue.data.number}`)
+ .setLabel(`Open Issue #${issueNumber ? issueNumber : "0"}`)
.setStyle(ButtonStyle.Link)
- .setURL(`https://github.com/ClicksMinutePer/Nucleus/issues/${issue.data.number}`)
+ .setURL(`https://github.com/ClicksMinutePer/Nucleus/issues/${issueNumber}`)
+ .setDisabled(disabled)
),
new Discord.ActionRowBuilder<ButtonBuilder>().addComponents(
- new ButtonBuilder().setCustomId("lock:Suggestion").setLabel("Lock").setStyle(ButtonStyle.Danger),
- new ButtonBuilder().setCustomId("spam:Suggestion").setLabel("Mark as Spam").setStyle(ButtonStyle.Danger)
+ new ButtonBuilder().setCustomId("lock:Comment").setLabel("Lock").setStyle(ButtonStyle.Danger).setDisabled(disabled),
+ new ButtonBuilder().setCustomId("spam:Suggestion").setLabel("Mark as Spam").setStyle(ButtonStyle.Danger).setDisabled(disabled)
)
]
});
diff --git a/src/reflex/guide.ts b/src/reflex/guide.ts
index 59c12c7..1b463cf 100644
--- a/src/reflex/guide.ts
+++ b/src/reflex/guide.ts
@@ -16,35 +16,47 @@
import createPageIndicator from "../utils/createPageIndicator.js";
import { Embed } from "../utils/defaults.js";
-export default async (guild: Guild, interaction?: CommandInteraction) => {
- let c: GuildTextBasedChannel | null = guild.publicUpdatesChannel ? guild.publicUpdatesChannel : guild.systemChannel;
- c = c
- ? c
- : (guild.channels.cache.find(
- (ch) =>
- [
- ChannelType.GuildText,
- ChannelType.GuildAnnouncement,
- ChannelType.PublicThread,
- ChannelType.PrivateThread,
- ChannelType.AnnouncementThread
- ].includes(ch.type) &&
- ch.permissionsFor(guild.roles.everyone).has("SendMessages") &&
- ch.permissionsFor(guild.members.me!).has("EmbedLinks")
- ) as GuildTextBasedChannel | undefined) ?? null;
- if (interaction) c = interaction.channel as GuildTextBasedChannel;
- if (!c) {
- return;
- }
+export default async (guild: Guild | null, interaction?: CommandInteraction) => {
let m: Message;
- if (interaction) {
- m = (await interaction.reply({
- embeds: LoadingEmbed,
- fetchReply: true,
- ephemeral: true
- })) as Message;
+ if (guild) {
+ let c: GuildTextBasedChannel | null = guild.publicUpdatesChannel ? guild.publicUpdatesChannel : guild.systemChannel;
+ c = c
+ ? c
+ : (guild.channels.cache.find(
+ (ch) =>
+ [
+ ChannelType.GuildText,
+ ChannelType.GuildAnnouncement,
+ ChannelType.PublicThread,
+ ChannelType.PrivateThread,
+ ChannelType.AnnouncementThread
+ ].includes(ch.type) &&
+ ch.permissionsFor(guild.roles.everyone).has("SendMessages") &&
+ ch.permissionsFor(guild.members.me!).has("EmbedLinks")
+ ) as GuildTextBasedChannel | undefined) ?? null;
+ if (interaction) c = interaction.channel as GuildTextBasedChannel;
+ if (!c) {
+ return;
+ }
+ if (interaction) {
+ m = (await interaction.reply({
+ embeds: LoadingEmbed,
+ fetchReply: true,
+ ephemeral: true
+ })) as Message;
+ } else {
+ m = await c.send({ embeds: LoadingEmbed });
+ }
} else {
- m = await c.send({ embeds: LoadingEmbed });
+ if (interaction) {
+ m = (await interaction.reply({
+ embeds: LoadingEmbed,
+ fetchReply: true,
+ ephemeral: true
+ })) as Message;
+ } else {
+ return;
+ }
}
let page = 0;
const pages = [
diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index 0e4a9b4..f5aaa6b 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -226,7 +226,7 @@
try {
component = await m.awaitMessageComponent({
filter: (i) =>
- i.user.id === this.interaction.user.id && i.channel!.id === this.interaction.channel!.id,
+ i.user.id === this.interaction.user.id && (i.channel ? (i.channel!.id === this.interaction.channel!.id) : true),
time: 300000
});
} catch (e) {
diff --git a/src/utils/dualCollector.ts b/src/utils/dualCollector.ts
index e96ff5d..28fa2bc 100644
--- a/src/utils/dualCollector.ts
+++ b/src/utils/dualCollector.ts
@@ -54,7 +54,7 @@
return i.channel!.id === m.channel!.id && i.user.id === user.id;
}
function defaultModalFilter(i: ModalSubmitInteraction, user: User, m: Message) {
- return i.channel!.id === m.channel!.id && i.user.id === user.id;
+ return (i.channel ? (i.channel!.id === m.channel!.id) : true) && i.user.id === user.id;
}
export async function modalInteractionCollector(