SHARE
TWEET

Untitled

TheInfiniteCode May 19th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import discord
  2. from discord.ext import commands
  3. import json
  4. from config import config
  5. from emojis import emoji
  6. import time
  7. from discord.ext.commands import MemberConverter
  8.  
  9. mention = "<@534087309365346304>"
  10. r = "<:unsuccess:577706577537007617>"
  11. g = "<:success:577706492887564290>"
  12.  
  13. def color():
  14.     return 0x42ebf4
  15.  
  16. def footer():
  17.     n = time.strftime("%p")
  18.     if n == "AM": n = "de."
  19.     else: n = "du."
  20.     return time.strftime("StormBot | {} %H:%M".format(n))
  21.  
  22. def getPrefix(server):
  23.     with open("prefix.json", "r") as f:
  24.         data = json.load(f)
  25.     if server in data:
  26.         return data[server]
  27.     return None
  28.  
  29. def setPrefix(server, prefix):
  30.     with open("prefix.json", "r") as f:
  31.         data = json.load(f)
  32.     data[server] = prefix
  33.     with open("prefix.json", "w") as f:
  34.         json.dump(data, f)
  35.  
  36. async def get_avatar(user: discord.Member):
  37.     return user.avatar_url
  38.  
  39. class Commands:
  40.     def __init__(self, client):
  41.         self.client = client
  42.  
  43.  
  44.     async def on_message(self, message):
  45.         if message.content.startswith(mention):
  46.             if not message.server == None:
  47.                 prefix = getPrefix(message.server.id)
  48.                 if prefix == None:
  49.                     prefix = "!"
  50.                 embed = discord.Embed(title = "Információk", colour = color(), description = "Prefixem ezen a szerveren: `{}`".format(prefix))
  51.                 embed.set_footer(text = footer())
  52.                 return await self.client.send_message(message.channel, embed = embed)
  53.  
  54.         channel = message.channel
  55.         user = message.author
  56.         prefix = "!"
  57.  
  58.         if message.server != None:
  59.             prefix = getPrefix(message.server.id)
  60.             if prefix == None:
  61.                 prefix = "!"
  62.         if not message.content.startswith(prefix):
  63.             return
  64.         msg = message.content.split()
  65.         print("gút")
  66.  
  67.         if msg[0] == prefix + "setprefix" or msg[0] == prefix + "prefix":
  68.             print("lol__")
  69.             if message.server == None:
  70.                 embed = discord.Embed(title = "{} Hiba!".format(r), colour = color(), description = config["nopm"])
  71.                 embed.set_footer(text = footer())
  72.                 return await self.client.send_message(channel, embed = embed)
  73.             if not user.server_permissions.administrator:
  74.                 embed = discord.Embed(title = "{} Hiba!".format(r), colour = color, description = config["noperm"])
  75.                 embed.set_footer(text = footer())
  76.                 return await self.client.send_message(channel, embed = embed)
  77.             if not len(msg) > 1:
  78.                 embed = discord.Embed(title = "{} Hiba!".format(r), colour = color(), description = f"Használat: `{prefix}setprefix [prefix]`")
  79.                 embed.set_footer(text = footer())
  80.                 return await self.client.send_message(channel, embed = embed)
  81.             if mention in msg[1]:
  82.                 embed = discord.Embed(title = "{} Hiba!".format(r), colour = color(), description = f"A prefix nem tartalmazhatja a {mention} szót")
  83.                 embed.set_footer(text = footer())
  84.                 return await self.client.send_message(channel, embed = embed)
  85.             newprefix = msg[1]
  86.             setPrefix(message.server.id, newprefix)
  87.             embed = discord.Embed(title = "{} Sikeres konfigurálás".format(g), colour = color(), description = f"Prefix megváltoztatva a következőre: `{newprefix}`")
  88.             embed.set_footer(text = footer())
  89.             return await self.client.send_message(channel, embed = embed)
  90.  
  91.  
  92.  
  93.         elif msg[0] == prefix + "avatar":
  94.             print("heeeeeeeeeeeeeeeeeeeeeeeeeeeeee?")
  95.             if len(msg) > 1:
  96.                 member: discord.Member = msg[1]
  97.             else:
  98.                 member = user
  99.             url = None
  100.             try:
  101.                 url = await get_avatar(member)
  102.             except:
  103.                 return await self.client.send_message(channel, ":x: Nincs ilyen felhasználó")
  104.             embed = discord.Embed(title = f"{member} profilképje", colour = color())
  105.             embed.set_image(url = url)
  106.             embed.set_footer(text = footer())
  107.             return await self.client.send_message(channel, embed = embed)
  108.            
  109.         print("pls")
  110.  
  111. def setup(client):
  112.     client.add_cog(Commands(client))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top