def start_raid_group(user, message, description):
"""Starts a new raid group."""
global should_refresh_active_raids
# get the server, use the message because user might be a webhook with no server
server = message.server
# find an available raid channel
channel = get_available_raid_channel(server)
if channel:
# lock the channel
locked_channels.add(channel)
# purge all messages
await client.purge_from(channel)
try:
# set the topic
await client.edit_channel(channel, topic=encode_message(user, message))
# create a role with the same name as this channel
role = await client.create_role(server, name=channel.name, mentionable=True)
# calculate expiration time
expiration_dt = adjusted_datetime(get_raid_expiration(message.timestamp))
summary_message = await client.send_message(channel, embed=get_raid_summary_embed(user, channel.name, expiration_dt, description))
# add shortcut reactions for commands
await client.add_reaction(summary_message, get_leave_emoji())
# set channel permissions to make raid viewers see the raid.
perms = discord.PermissionOverwrite(read_messages=True)
role = await get_raid_viewer_role(server)
if role is not None:
await client.edit_channel_permissions(channel, role, perms)
finally:
# unlock the channel
locked_channels.remove(channel)
# refresh active raids in future
should_refresh_active_raids = True
return channel
评论列表
文章目录