39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
import discord
|
|
from discord.ext import commands
|
|
from functions.checks import *
|
|
import requests
|
|
from io import BytesIO
|
|
|
|
class SuggestionMessage(commands.Cog):
|
|
def __init__(self, client):
|
|
self.client = client
|
|
self.channels = ["740308147385663518", "761327043894968330"]
|
|
|
|
@commands.command(name="suggestion")
|
|
async def suggestion(self, ctx, *, arg):
|
|
if str(ctx.channel.id) in self.channels or isModPlus(ctx):
|
|
embed = discord.Embed()
|
|
embed.set_author(name=ctx.author.display_name)
|
|
embed.colour = discord.Colour.orange()
|
|
embed.description = f"{arg}"
|
|
if len(ctx.message.attachments) > 0:
|
|
attachment_url = ctx.message.attachments[0].url
|
|
embed.set_image(url="attachment://image.png")
|
|
message = await ctx.send(embed=embed, file=self.get_image_from_url(attachment_url))
|
|
else:
|
|
message = await ctx.send(embed=embed)
|
|
await ctx.message.delete()
|
|
await message.add_reaction("✅")
|
|
await message.add_reaction("❌")
|
|
|
|
def get_image_from_url(self, url):
|
|
res = requests.get(url)
|
|
arr = BytesIO(res.content)
|
|
arr.seek(0)
|
|
file=discord.File(fp=arr, filename='image.png')
|
|
return file
|
|
|
|
|
|
def setup(client):
|
|
client.add_cog(SuggestionMessage(client))
|