Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #49 from takejohn/45-follow_announcements-error
Browse files Browse the repository at this point in the history
/follow_announcementsのエラー (#45)
  • Loading branch information
ringo360 authored Feb 29, 2024
2 parents 3616104 + 1e811bc commit ac35031
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions commands/receiveupdate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { SlashCommandBuilder, ChannelType, PermissionsBitField, CommandInteraction } = require('discord.js');
const assert = require('assert');
const { SlashCommandBuilder, ChannelType, PermissionsBitField, CommandInteraction, Client, NewsChannel } = require('discord.js');
const config = require('../config.json')
const { LANG } = require('../util/languages');

Expand All @@ -13,20 +14,24 @@ module.exports = {
.addChannelTypes(ChannelType.GuildText)
.setRequired(true)
),
execute: async function (/** @type {CommandInteraction} */ interaction, client) {
execute: async function (
/** @type {CommandInteraction} */ interaction,
/** @type {Client} */ client) {
await interaction.deferReply()
if (!interaction.member.permissions.has(PermissionsBitField.Flags.Administrator)) {
return await interaction.editReply('権限がありません!(管理者権限が必要です。)')
}
const targetchannel = interaction.options.getChannel('channel');
client.channels.resolve("1211695901760819281").addFollower(targetchannel.id) //TODO: config.jsonで編集可能に?
.then(() =>
console.log(`[Sekai.Explode] new follower! ${interaction.guild.name} - ${interaction.guild.id}`),
interaction.editReply(`<#${targetchannel.id}>にSekai.Explodeのアナウンスを通知します :wave:`)
)
.catch((e) =>
console.log(`Something Went wrong. ${e}`),
interaction.editReply(`失敗しました!エラー: ${e}`)
)

const channel = client.channels.resolve("1211695901760819281"); //TODO: config.jsonで編集可能に?
assert(channel instanceof NewsChannel);
try {
await channel.addFollower(targetchannel.id);
console.log(`[Sekai.Explode] new follower! ${interaction.guild.name} - ${interaction.guild.id}`),
await interaction.editReply(`<#${targetchannel.id}>にSekai.Explodeのアナウンスを通知します :wave:`)
} catch (e) {
console.log(`Something Went wrong. ${e}`),
await interaction.editReply(`失敗しました!エラー: ${e}`)
}
}
};

0 comments on commit ac35031

Please sign in to comment.