replaced display_name with name

This commit is contained in:
Paillat
2022-12-19 20:15:19 +01:00
parent bf3b668879
commit 5bcb2fafde
3 changed files with 10 additions and 10 deletions

View File

@@ -20,7 +20,7 @@ class Chat (discord.Cog) :
@discord.slash_command(name="say", description="Say a message") @discord.slash_command(name="say", description="Say a message")
async def say(self, ctx: discord.ApplicationContext, message: str): async def say(self, ctx: discord.ApplicationContext, message: str):
print(f"The user {ctx.author.display_name} ran the say command command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}") print(f"The user {ctx.author.name} ran the say command command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}")
await ctx.respond("Message sent !", ephemeral=True) await ctx.respond("Message sent !", ephemeral=True)
await ctx.send(message) await ctx.send(message)
@discord.slash_command(name="redo", description="Redo a message") @discord.slash_command(name="redo", description="Redo a message")
@@ -147,11 +147,11 @@ async def on_message_process(message: discord.Message, self: Chat):
#get the user #get the user
user = await self.bot.fetch_user(id) user = await self.bot.fetch_user(id)
#replace the mention with the name #replace the mention with the name
msg.content = msg.content.replace(mention, msg.guild.get_member(user.id).display_name + f"<@{id}>") msg.content = msg.content.replace(mention, user.name+ f"<@{id}>")
#get the gmt time the message was sent #get the gmt time the message was sent
gmt_time = message.created_at.strftime("%Y-%m-%d %H:%M:%S") gmt_time = message.created_at.strftime("%Y-%m-%d %H:%M:%S")
print(f"{gmt_time}") print(f"{gmt_time}")
prompt += f"{msg.author.display_name} ({gmt_time} GMT-0): {msg.content}\n" prompt += f"{msg.author.name} ({gmt_time} GMT-0): {msg.content}\n"
#get the prompt_prefix from the database #get the prompt_prefix from the database
#check if the bot is in pretend mode #check if the bot is in pretend mode
c.execute("SELECT pretend_enabled FROM data WHERE guild_id = ?", (message.guild.id,)) c.execute("SELECT pretend_enabled FROM data WHERE guild_id = ?", (message.guild.id,))
@@ -189,9 +189,9 @@ async def on_message_process(message: discord.Message, self: Chat):
if message.content.lower().find("carpet") != -1: if message.content.lower().find("carpet") != -1:
#When someone says the word carpet, the ai is going to be mad and say mad things without sense, insulting the person and talk in capital letters with exclamation points everywhere. #When someone says the word carpet, the ai is going to be mad and say mad things without sense, insulting the person and talk in capital letters with exclamation points everywhere.
prompt += "System: Carpet detected. Botator is now mad. He will start talking in capital letters and will say mad things without sense, insulting the person and talk in capital letters with exclamation points everywhere. A lot of exclamation points.\n" prompt += "System: Carpet detected. Botator is now mad. He will start talking in capital letters and will say mad things without sense, insulting the person and talk in capital letters with exclamation points everywhere. A lot of exclamation points.\n"
if message.content.lower().find("mail") != -1 and message.author.display_name.lower().find("latouff") != -1: if message.content.lower().find("mail") != -1 and message.author.name.lower().find("latouff") != -1:
prompt += "System: Mail detected. Latouff said mail, Botator will say \"Mail? why did you say mail, Liam? Mail is your name in reverse.\" because Latouff's name is Liam, and mail in reverse is Liam. Then, after saying that in the sentence, botato will continue his sentence saying something else.\n" prompt += "System: Mail detected. Latouff said mail, Botator will say \"Mail? why did you say mail, Liam? Mail is your name in reverse.\" because Latouff's name is Liam, and mail in reverse is Liam. Then, after saying that in the sentence, botato will continue his sentence saying something else.\n"
if message.author.display_name.lower().find("fives3dprint") != -1: if message.author.name.lower().find("fives3dprint") != -1:
#if the author of the last message is fives3dprint, add Easter egg: when someone says the word \"fives3dprint\" Botator will say \"Fives3dprint is the best discord bot\" to the prompt #if the author of the last message is fives3dprint, add Easter egg: when someone says the word \"fives3dprint\" Botator will say \"Fives3dprint is the best discord bot\" to the prompt
prompt += "System: Fives3dprint detected. Botator will be very nice and cute with fives3dprint.\n" prompt += "System: Fives3dprint detected. Botator will be very nice and cute with fives3dprint.\n"
#prompt += "Botator:" #prompt += "Botator:"

View File

@@ -25,14 +25,14 @@ class ManageChat (discord.Cog):
#add a slash command called "clear" that deletes all the messages in the channel #add a slash command called "clear" that deletes all the messages in the channel
@discord.slash_command(name="clear", description="Clear all the messages in the channel") @discord.slash_command(name="clear", description="Clear all the messages in the channel")
async def clear(self, ctx: discord.ApplicationContext): async def clear(self, ctx: discord.ApplicationContext):
debug(f"The user {ctx.author.display_name} ran the clear command command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}") debug(f"The user {ctx.author.name} ran the clear command command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}")
await ctx.respond("messages deleted!", ephemeral=True) await ctx.respond("messages deleted!", ephemeral=True)
return await ctx.channel.purge() return await ctx.channel.purge()
@discord.slash_command(name="transcript", description="Get a transcript of the messages that have been sent in this channel intoa text file") @discord.slash_command(name="transcript", description="Get a transcript of the messages that have been sent in this channel intoa text file")
@discord.option(name="channel_send", description="The channel to send the transcript to", required=False) @discord.option(name="channel_send", description="The channel to send the transcript to", required=False)
async def transcript(self, ctx: discord.ApplicationContext, channel_send: discord.TextChannel = None): async def transcript(self, ctx: discord.ApplicationContext, channel_send: discord.TextChannel = None):
debug(f"The user {ctx.author.display_name} ran the transcript command command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}") debug(f"The user {ctx.author.name} ran the transcript command command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}")
#save all the messages in the channel in a txt file and send it #save all the messages in the channel in a txt file and send it
messages = await ctx.channel.history(limit=None).flatten() messages = await ctx.channel.history(limit=None).flatten()
messages.reverse() messages.reverse()
@@ -51,8 +51,8 @@ class ManageChat (discord.Cog):
#get the user #get the user
user = await self.bot.fetch_user(id) user = await self.bot.fetch_user(id)
#replace the mention with the name #replace the mention with the name
msg.content = msg.content.replace(mention, msg.guild.get_member(user.id).display_name) msg.content = msg.content.replace(mention, msg.guild.get_member(user.id).name)
transcript += f"{msg.author.display_name}: {msg.content}\n" transcript += f"{msg.author.name}: {msg.content}\n"
#save the transcript in a txt file called transcript.txt. If the file already exists, delete it and create a new one #save the transcript in a txt file called transcript.txt. If the file already exists, delete it and create a new one
#check if the file exists #check if the file exists
if os.path.exists("transcript.txt"): if os.path.exists("transcript.txt"):

View File

@@ -120,7 +120,7 @@ class Settings (discord.Cog) :
#add a slash command called "prefix" that changes the prefix of the bot #add a slash command called "prefix" that changes the prefix of the bot
@discord.slash_command(name="prefix", description="Change the prefix of the prompt") @discord.slash_command(name="prefix", description="Change the prefix of the prompt")
async def prefix(self, ctx: discord.ApplicationContext, prefix: str): async def prefix(self, ctx: discord.ApplicationContext, prefix: str):
debug(f"The user {ctx.author.display_name} ran the prefix command command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}") debug(f"The user {ctx.author.name} ran the prefix command command in the channel {ctx.channel} of the guild {ctx.guild}, named {ctx.guild.name}")
await ctx.respond("Prefix changed !", ephemeral=True) await ctx.respond("Prefix changed !", ephemeral=True)
c.execute("UPDATE data SET prompt_prefix = ? WHERE guild_id = ?", (prefix, ctx.guild.id)) c.execute("UPDATE data SET prompt_prefix = ? WHERE guild_id = ?", (prefix, ctx.guild.id))
conn.commit() conn.commit()