mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 11:48:55 -05:00
[Owner] Added embed to [p]contact
This commit is contained in:
parent
7820319a6a
commit
e9e4fd083f
@ -673,26 +673,42 @@ class Owner:
|
|||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@commands.cooldown(1, 60, commands.BucketType.user)
|
@commands.cooldown(1, 60, commands.BucketType.user)
|
||||||
async def contact(self, ctx, *, message : str):
|
async def contact(self, ctx, *, message : str):
|
||||||
"""Sends message to the owner"""
|
"""Sends a message to the owner"""
|
||||||
if self.bot.settings.owner is None:
|
if self.bot.settings.owner is None:
|
||||||
await self.bot.say("I have no owner set.")
|
await self.bot.say("I have no owner set.")
|
||||||
return
|
return
|
||||||
|
server = ctx.message.server
|
||||||
owner = discord.utils.get(self.bot.get_all_members(),
|
owner = discord.utils.get(self.bot.get_all_members(),
|
||||||
id=self.bot.settings.owner)
|
id=self.bot.settings.owner)
|
||||||
author = ctx.message.author
|
author = ctx.message.author
|
||||||
if ctx.message.channel.is_private is False:
|
footer = "User ID: " + author.id
|
||||||
server = ctx.message.server
|
|
||||||
source = ", server **{}** ({})".format(server.name, server.id)
|
if ctx.message.server is None:
|
||||||
|
source = "through DM"
|
||||||
else:
|
else:
|
||||||
source = ", direct message"
|
source = "from {}".format(server)
|
||||||
sender = "From **{}** ({}){}:\n\n".format(author, author.id, source)
|
footer += " | Server ID: " + server.id
|
||||||
message = sender + message
|
|
||||||
|
if isinstance(author, discord.Member):
|
||||||
|
colour = author.colour
|
||||||
|
else:
|
||||||
|
colour = discord.Colour.red()
|
||||||
|
|
||||||
|
description = "Sent by {} {}".format(author, source)
|
||||||
|
|
||||||
|
e = discord.Embed(colour=colour, description=message)
|
||||||
|
if author.avatar_url:
|
||||||
|
e.set_author(name=description, icon_url=author.avatar_url)
|
||||||
|
else:
|
||||||
|
e.set_author(name=description)
|
||||||
|
e.set_footer(text=footer)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.bot.send_message(owner, message)
|
await self.bot.send_message(owner, embed=e)
|
||||||
except discord.errors.InvalidArgument:
|
except discord.InvalidArgument:
|
||||||
await self.bot.say("I cannot send your message, I'm unable to find"
|
await self.bot.say("I cannot send your message, I'm unable to find"
|
||||||
" my owner... *sigh*")
|
" my owner... *sigh*")
|
||||||
except discord.errors.HTTPException:
|
except discord.HTTPException:
|
||||||
await self.bot.say("Your message is too long.")
|
await self.bot.say("Your message is too long.")
|
||||||
except:
|
except:
|
||||||
await self.bot.say("I'm unable to deliver your message. Sorry.")
|
await self.bot.say("I'm unable to deliver your message. Sorry.")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user