mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
fix: fix error when trying to fetch an unknown channel in role buttons
This commit is contained in:
parent
75bd7625a2
commit
44d68bf608
1 changed files with 3 additions and 3 deletions
|
@ -18,7 +18,7 @@ export async function applyRoleButtons(
|
||||||
|
|
||||||
// Remove existing role buttons, if any
|
// Remove existing role buttons, if any
|
||||||
if (existingSavedButtons?.channel_id) {
|
if (existingSavedButtons?.channel_id) {
|
||||||
const existingChannel = await pluginData.guild.channels.fetch(configItem.message.channel_id);
|
const existingChannel = await pluginData.guild.channels.fetch(configItem.message.channel_id).catch(() => null);
|
||||||
const existingMessage = await (existingChannel?.isText() &&
|
const existingMessage = await (existingChannel?.isText() &&
|
||||||
existingChannel.messages.fetch(existingSavedButtons.message_id).catch(() => null));
|
existingChannel.messages.fetch(existingSavedButtons.message_id).catch(() => null));
|
||||||
if (existingMessage && existingMessage.components.length) {
|
if (existingMessage && existingMessage.components.length) {
|
||||||
|
@ -31,7 +31,7 @@ export async function applyRoleButtons(
|
||||||
// Find or create message for role buttons
|
// Find or create message for role buttons
|
||||||
if ("message_id" in configItem.message) {
|
if ("message_id" in configItem.message) {
|
||||||
// channel id + message id: apply role buttons to existing message
|
// channel id + message id: apply role buttons to existing message
|
||||||
const channel = await pluginData.guild.channels.fetch(configItem.message.channel_id);
|
const channel = await pluginData.guild.channels.fetch(configItem.message.channel_id).catch(() => null);
|
||||||
const messageCandidate = await (channel?.isText() &&
|
const messageCandidate = await (channel?.isText() &&
|
||||||
channel.messages.fetch(configItem.message.message_id).catch(() => null));
|
channel.messages.fetch(configItem.message.message_id).catch(() => null));
|
||||||
if (!messageCandidate) {
|
if (!messageCandidate) {
|
||||||
|
@ -54,7 +54,7 @@ export async function applyRoleButtons(
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const channel = await pluginData.guild.channels.fetch(configItem.message.channel_id);
|
const channel = await pluginData.guild.channels.fetch(configItem.message.channel_id).catch(() => null);
|
||||||
if (!channel || !channel.isText()) {
|
if (!channel || !channel.isText()) {
|
||||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||||
body: `Text channel not found for role_buttons/${configItem.name}`,
|
body: `Text channel not found for role_buttons/${configItem.name}`,
|
||||||
|
|
Loading…
Add table
Reference in a new issue