restrict announcements to admins
This commit is contained in:
parent
e50cb10c5b
commit
a2c55ad676
@ -1,4 +1,4 @@
|
||||
import { Guild, GuildScheduledEvent, GuildScheduledEventEditOptions, GuildScheduledEventSetStatusArg, GuildScheduledEventStatus, Message, MessageCreateOptions, MessageEditOptions, TextChannel, messageLink } from 'discord.js'
|
||||
import { Guild, GuildMember, GuildScheduledEvent, GuildScheduledEventEditOptions, GuildScheduledEventSetStatusArg, GuildScheduledEventStatus, Message, MessageCreateOptions, MessageEditOptions, TextChannel, messageLink } from 'discord.js'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import { config } from '../configuration'
|
||||
import { Emotes } from '../events/guildScheduledEventCreate'
|
||||
@ -16,23 +16,36 @@ export default new Command({
|
||||
const requestId = uuid()
|
||||
const guildId = command.guildId!
|
||||
logger.info("Got command for announcing!", { guildId, requestId })
|
||||
const announcementChannel: TextChannel = client.getAnnouncementChannelForGuild(guildId)
|
||||
|
||||
const body = `Hey! @everyone! Hier ist der Watchparty Bot vom Hartzarett.
|
||||
if (!isAdmin(command.member)) {
|
||||
logger.info(`Announcement was requested by ${command.member.displayName} but they are not an admin! Not sending announcement.`, { guildId, requestId })
|
||||
return
|
||||
} else {
|
||||
logger.info(`User ${command.member.displayName} seems to be admin`)
|
||||
}
|
||||
sendAnnouncement(guildId, requestId)
|
||||
command.followUp("Ist rausgeschickt!")
|
||||
}
|
||||
})
|
||||
|
||||
function isAdmin(member: GuildMember): boolean {
|
||||
return member.roles.cache.find((role, _) => role.id === config.bot.jf_admin_role) != undefined
|
||||
}
|
||||
|
||||
async function sendAnnouncement(guildId: string, requestId: string): Promise<void> {
|
||||
logger.info("Sending announcement")
|
||||
const announcementChannel: TextChannel = client.getAnnouncementChannelForGuild(guildId)
|
||||
|
||||
const body = `Hey! @everyone! Hier ist der Watchparty Bot vom Hartzarett.
|
||||
|
||||
Wir machen in Zukunft regelmäßig Watchparties! Falls du mitmachen möchtest, reagiere einfach auf diesen Post mit 🎫, dann bekommst du automatisch eine Rolle zugewiesen und wirst benachrichtigt sobald es in der Zukunft weitere Watchparties und Filme zum abstimmen gibt.
|
||||
|
||||
Für eine Erklärung wie das alles funktioniert mach einfach /mitgucken für eine lange Erklärung am Stück oder /guides wenn du auswählen möchtest wozu du Infos bekommst.`
|
||||
|
||||
const options: MessageCreateOptions = {
|
||||
allowedMentions: { parse: ['everyone'] },
|
||||
content: body
|
||||
}
|
||||
|
||||
const message: Message<true> = await announcementChannel.send(options)
|
||||
|
||||
message.react("🎫")
|
||||
|
||||
command.followUp("Ist rausgeschickt!")
|
||||
const options: MessageCreateOptions = {
|
||||
allowedMentions: { parse: ['everyone'] },
|
||||
content: body
|
||||
}
|
||||
})
|
||||
const message: Message<true> = await announcementChannel.send(options)
|
||||
message.react("🎫")
|
||||
}
|
Loading…
Reference in New Issue
Block a user