Vote channel no longer exist. Announcements channel used instead

This commit is contained in:
Elnath 2021-07-01 14:42:36 +02:00
parent b4bad89089
commit 77678878cc
1 changed files with 7 additions and 19 deletions

View File

@ -155,14 +155,6 @@ class Game:
def get_announcements_channel(self) -> discord.TextChannel:
return self.guild.get_channel(self.get_announcements_channel_id())
@game_started
def get_votes_channel_id(self) -> int:
return self.config["votes_chan"]
@game_started
def get_votes_channel(self) -> discord.TextChannel:
return self.guild.get_channel(self.get_votes_channel_id())
@game_started
def get_gm_channel_id(self) -> int:
return self.config["admin_chan"]
@ -265,18 +257,14 @@ class Game:
logger.debug(f"[{self.guild.name}] Created admin channel")
tasks.append(asyncio.create_task(create_admin_chan()))
async def create_announcements_and_vote_chans():
async def create_announcements_chan():
perms = {
self.guild.default_role: discord.PermissionOverwrite(send_messages = False),
gm_role: discord.PermissionOverwrite(send_messages = True),
}
announcements_chan, votes_chan = await asyncio.gather(
game_category.create_text_channel("announcements", overwrites = perms, position = 1),
game_category.create_text_channel("votes", overwrites = perms, position = 2)
)
announcements_chan = await game_category.create_text_channel("announcements", overwrites = perms, position = 1)
self.config["announce_chan"] = announcements_chan.id
self.config["votes_chan"] = votes_chan.id
logger.debug(f"[{self.guild.name}] Created announcements and votes channels")
logger.debug(f"[{self.guild.name}] Created announcements channel")
async def announce_game_start():
message_content = [
@ -290,7 +278,7 @@ class Game:
await message.pin()
logger.debug(f"[{self.guild.name}] Announced game start in announcements")
asyncio.create_task(announce_game_start()) # We do not add it to the list of tasks to wait before game creation finishes because we do not care if it is executed after a while
tasks.append(asyncio.create_task(create_announcements_and_vote_chans()))
tasks.append(asyncio.create_task(create_announcements_chan()))
async def create_discussion_chan():
# Permissions are inherited from the category so they are synced to it
@ -385,9 +373,9 @@ class Game:
message_content.append("**The vote has ended**")
message_content_str = "\n".join(message_content)
if self.config["vote"]["message"] is None:
self.config["vote"]["message"] = (await self.get_votes_channel().send(message_content_str, allowed_mentions = discord.AllowedMentions(users = True))).id
self.config["vote"]["message"] = (await self.get_announcements_channel().send(message_content_str, allowed_mentions = discord.AllowedMentions(users = True))).id
else:
await (await self.get_votes_channel().fetch_message(self.config["vote"]["message"])).edit(content = message_content_str, allowed_mentions = discord.AllowedMentions(users = True))
await (await self.get_announcements_channel().fetch_message(self.config["vote"]["message"])).edit(content = message_content_str, allowed_mentions = discord.AllowedMentions(users = True))
@vote_running
@save_on_success
@ -432,7 +420,7 @@ class Game:
vote_message_id = self.config["vote"]["message"]
self.config["vote"] = None
if vote_message_id is not None:
await (await self.get_votes_channel().fetch_message(vote_message_id)).edit(content = "~~The vote has been canceled~~")
await (await self.get_announcements_channel().fetch_message(vote_message_id)).edit(content = "~~The vote has been canceled~~")
@game_started
@save_on_success