Messaging the bot redirects message to maintainer
This commit is contained in:
parent
32d3f05dd3
commit
ed9031a1d9
37
akuma.py
37
akuma.py
@ -1,4 +1,4 @@
|
|||||||
import json, discord
|
import json, discord, io
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ext.commands import CommandNotFound
|
from discord.ext.commands import CommandNotFound
|
||||||
|
|
||||||
@ -41,6 +41,41 @@ async def on_command_error(ctx, error):
|
|||||||
return
|
return
|
||||||
raise error
|
raise error
|
||||||
|
|
||||||
|
@bot.event
|
||||||
|
async def on_message(message):
|
||||||
|
if message.guild == None and message.author.bot == False and message.content[:len(bot.command_prefix)] != bot.command_prefix:
|
||||||
|
user = bot.get_user(c["maintainer"])
|
||||||
|
if user is not None:
|
||||||
|
e = discord.Embed(color=0xc83232)
|
||||||
|
e.set_author(name = str(message.author) + " sent a DM.", icon_url=message.author.avatar_url)
|
||||||
|
e.add_field(name="Profile", value=message.author.mention, inline=False)
|
||||||
|
if message.content:
|
||||||
|
e.add_field(name="Content", value=message.content, inline=False)
|
||||||
|
numAtch = len(message.attachments)
|
||||||
|
if numAtch == 0:
|
||||||
|
await user.send(embed=e)
|
||||||
|
elif numAtch == 1:
|
||||||
|
x = io.BytesIO()
|
||||||
|
await message.attachments[0].save(x)
|
||||||
|
name = message.attachments[0].filename
|
||||||
|
f = discord.File(x, filename = name)
|
||||||
|
extention = name.split(".")[-1]
|
||||||
|
if extention in ["jpg", "jpeg", "png", "webp", "gif"]:
|
||||||
|
e.set_image(url = "attachment://"+name)
|
||||||
|
await user.send(embed=e, file=f)
|
||||||
|
else:
|
||||||
|
e.add_field(name="Attachment",value=name, inline=False)
|
||||||
|
await user.send(embed=e)
|
||||||
|
await user.send(file=f)
|
||||||
|
else:
|
||||||
|
e.add_field(name="Attachments",value=str(numAtch)+" Attachments sent", inline=False)
|
||||||
|
await user.send(embed=e)
|
||||||
|
for a in message.attachments:
|
||||||
|
x = io.BytesIO()
|
||||||
|
await a.save(x)
|
||||||
|
await user.send(file=discord.File(x, filename=a.filename))
|
||||||
|
await bot.process_commands(message)
|
||||||
|
|
||||||
@bot.command(hidden=True)
|
@bot.command(hidden=True)
|
||||||
async def printExt(ctx):
|
async def printExt(ctx):
|
||||||
"""Prints out every loaded extension"""
|
"""Prints out every loaded extension"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user