add insult context action (dm)

This commit is contained in:
2022-10-28 17:28:19 +02:00
parent efb9e4869b
commit 2e83bdfffe

41
bot.py
View File

@ -221,36 +221,25 @@ async def say_voiceline(interaction: discord.Interaction, sound: str):
await voice_client.disconnect() await voice_client.disconnect()
# Example # TODO: More insults
# Callable on members # Callable on members
@client.tree.context_menu(name='Show Join Date') @client.tree.context_menu(name="beleidigen")
async def show_join_date(interaction: discord.Interaction, member: discord.Member): async def insult(interaction: discord.Interaction, member: discord.Member): # with message: discord.Message this can be called on a message
# The format_dt function formats the date time into a human readable representation in the official client if not member.dm_channel:
await interaction.response.send_message(f'{member} joined at {discord.utils.format_dt(member.joined_at)}') await member.create_dm()
# Example if not member.dm_channel:
# Callable on messages print("Error creating DMChannel!")
@client.tree.context_menu(name='Report to Moderators') await interaction.response.send_message("Heidi sagt: Gib mal DM Nummer süße*r!")
async def report_message(interaction: discord.Interaction, message: discord.Message): return
# We're sending this response message with ephemeral=True, so only the command executor can see it
await interaction.response.send_message(
f'Thanks for reporting this message by {message.author.mention} to our moderators.', ephemeral=True
)
# Handle report by sending it into a log channel insults = [
log_channel = interaction.guild.get_channel(821511861178204164) # replace with your channel id "Du kleiner Hurensohn!",
"Fick dich!"
]
embed = discord.Embed(title='Reported Message') await member.dm_channel.send(random.choice(insults))
if message.content: await interaction.response.send_message("Anzeige ist raus!") # with ephemeral = True only the caller can see the answer
embed.description = message.content
embed.set_author(name=message.author.display_name, icon_url=message.author.display_avatar.url)
embed.timestamp = message.created_at
url_view = discord.ui.View()
url_view.add_item(discord.ui.Button(label='Go to Message', style=discord.ButtonStyle.url, url=message.jump_url))
await log_channel.send(embed=embed, view=url_view)
# ------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------