Get emotes only from channel's guild, fix mentions

This commit is contained in:
git-bruh 2020-11-25 12:05:07 +05:30
parent 91ce6584aa
commit 437f38ba85
No known key found for this signature in database
GPG key ID: E1475C50075ADCE6

20
main.py
View file

@ -112,21 +112,21 @@ async def process_matrix(message):
message = message.replace("@everyone", "@\u200Beveryone") message = message.replace("@everyone", "@\u200Beveryone")
message = message.replace("@here", "@\u200Bhere") message = message.replace("@here", "@\u200Bhere")
mention_list = re.findall(r"(^|\s)(@(\w*))", message) mentions = re.findall(r"(^|\s)(@(\w*))", message)
for emote in message.split():
if emote[0] == emote[-1] == ":":
emote_ = discord.utils.get(discord_client.emojis, name=emote[1:-1])
if emote_:
message = message.replace(emote, str(emote_))
channel = await get_channel() channel = await get_channel()
guild = channel.guild guild = channel.guild
for mention in mention_list: for emote in message.split():
member = guild.get_member_named(mention[2]) if emote[0] == emote[-1] == ":":
emote_ = discord.utils.get(guild.emojis, name=emote[1:-1])
if emote_:
message = message.replace(emote, str(emote_))
for mention in mentions:
member = await guild.query_members(query=mention[2])
if member: if member:
message = message.replace(mention[1], member.mention) message = message.replace(mention[1], member[0].mention)
return message return message