Game: messages with player mentions now have permission to ping players to fix undefined-user problem on mobile

This commit is contained in:
Elnath 2021-06-21 23:25:48 +02:00
parent 1cb879aa09
commit b4bad89089
1 changed files with 5 additions and 5 deletions

View File

@ -286,7 +286,7 @@ class Game:
] ]
message_content.extend([f"· <@{player_id}>" for player_id in self.get_players_id()]) message_content.extend([f"· <@{player_id}>" for player_id in self.get_players_id()])
message_content.append("Have a nice game!") message_content.append("Have a nice game!")
message = await announcements_chan.send("\n".join(message_content), allowed_mentions = discord.AllowedMentions(roles = True)) message = await announcements_chan.send("\n".join(message_content), allowed_mentions = discord.AllowedMentions(roles = True, users = True))
await message.pin() await message.pin()
logger.debug(f"[{self.guild.name}] Announced game start in announcements") 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 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
@ -318,7 +318,7 @@ class Game:
player_channel = await game_category.create_text_channel(player.name, overwrites = perms, position = position) player_channel = await game_category.create_text_channel(player.name, overwrites = perms, position = position)
self.config["player_info"][str(player.id)]["channel"] = player_channel.id self.config["player_info"][str(player.id)]["channel"] = player_channel.id
logger.debug(f"[{self.guild.name}] Created channel for player {player.name}") logger.debug(f"[{self.guild.name}] Created channel for player {player.name}")
asyncio.create_task(player_channel.send(f"Hello! This is your private channel.\nIn here you can cast your votes, interact with the <@&{self.get_gm_role_id()}>, and write freely.\nHave a nice game!", allowed_mentions = discord.AllowedMentions.none())) asyncio.create_task(player_channel.send(f"Hello! This is your private channel.\nIn here you can cast your votes, interact with the <@&{self.get_gm_role_id()}>, and write freely.\nHave a nice game!", allowed_mentions = discord.AllowedMentions(roles = True)))
for i, player in enumerate(player_role.members): for i, player in enumerate(player_role.members):
tasks.append(asyncio.create_task(create_player_channel(player, 5 + i))) tasks.append(asyncio.create_task(create_player_channel(player, 5 + i)))
@ -385,9 +385,9 @@ class Game:
message_content.append("**The vote has ended**") message_content.append("**The vote has ended**")
message_content_str = "\n".join(message_content) message_content_str = "\n".join(message_content)
if self.config["vote"]["message"] is None: if self.config["vote"]["message"] is None:
self.config["vote"]["message"] = (await self.get_votes_channel().send(message_content_str, allowed_mentions = discord.AllowedMentions.none())).id self.config["vote"]["message"] = (await self.get_votes_channel().send(message_content_str, allowed_mentions = discord.AllowedMentions(users = True))).id
else: else:
await (await self.get_votes_channel().fetch_message(self.config["vote"]["message"])).edit(content = message_content_str, allowed_mentions = discord.AllowedMentions.none()) await (await self.get_votes_channel().fetch_message(self.config["vote"]["message"])).edit(content = message_content_str, allowed_mentions = discord.AllowedMentions(users = True))
@vote_running @vote_running
@save_on_success @save_on_success
@ -420,7 +420,7 @@ class Game:
announcement_content.append(":relaxed: The country has calmed and the chaos counter has been reset") announcement_content.append(":relaxed: The country has calmed and the chaos counter has been reset")
self.config["chaos"] = 0 # Anyway, the chaos is reset by a successful vote self.config["chaos"] = 0 # Anyway, the chaos is reset by a successful vote
self.config["vote"] = None self.config["vote"] = None
await self.get_announcements_channel().send("\n".join(announcement_content), allowed_mentions = discord.AllowedMentions(roles = True)) await self.get_announcements_channel().send("\n".join(announcement_content), allowed_mentions = discord.AllowedMentions(roles = True, users = True))
# After announcing a non-passing vote, we increase the chaos and announce it # After announcing a non-passing vote, we increase the chaos and announce it
if not passed: if not passed:
await self.increase_chaos() await self.increase_chaos()