Advertisement
PelucheZ

SetarMod

Dec 15th, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.60 KB | None | 0 0
  1. import  discord
  2. import asyncio
  3. from pymongo import MongoClient
  4. import pymongo
  5. from discord.ext import commands
  6.  
  7. bot = commands.Bot(command_prefix=['r%', 'r ', 'radio ', '%r', 'r-', 'r='], case_insensitive=True)
  8.  
  9. tempro = []
  10.  
  11. ulr = "mongodb://admin:251255rai@ds143163.mlab.com:43163/radioofficial"
  12.  
  13. COR = 0xFFA500
  14.  
  15. class suge():
  16.     def __init__(self, bot):
  17.         self.bot = bot
  18.  
  19.     async def on_guild_join(self, guild):
  20.         mongo = MongoClient(ulr)
  21.         radioofficial = mongo["radioofficial"]
  22.         mod = radioofficial["mod"]
  23.         a = {'Nome do servidor': str(guild.name), 'server id': str(guild.id), 'canal' : 'Nenhum canal setado'}
  24.         radioofficial.mod.insert_one(a).inserted_id
  25.  
  26.     async def on_guild_remove(self, guild):
  27.         mongo = MongoClient(ulr)
  28.         radioofficial = mongo["radioofficial"]
  29.         mod = radioofficial["mod"]
  30.         a = {'Nome do servidor': str(guild.name)}
  31.         radioofficial.mod.delete_one(a)
  32.  
  33.     async def on_message(self, message):
  34.         mongo = MongoClient(ulr)
  35.         radioofficial = mongo["radioofficial"]
  36.         mod = radioofficial["mod"]
  37.         ch = radioofficial.mod.find_one({'server id':str(message.guild.id)})
  38.         canal = ch['canal']
  39.         if message.author.bot:
  40.             pass
  41.         if canal == 'Nenhum canal setado':
  42.             return
  43.         @commands.command(name='ban', aliases=['banir'])
  44.         @commands.has_permissions(administrator=True)
  45.         @commands.guild_only()
  46.         async def ban(self, ctx, *, user: discord.Member=None):
  47.             if user is None:
  48.                 embed = discord.Embed(color=COR, description=f'**<:nook:518495958128918558> `{ctx.author}`, você precisa mencionar um usuário para banir**')
  49.                 embed.set_footer(text="RadioOfficial© 2018")
  50.                 await ctx.send(embed=embed)
  51.             else:
  52.                 if message.channel.id == canal:
  53.                     await ctx.guild.ban(user, reason=None, delete_message_days=0)
  54.                     embed = discord.Embed(color=COR, timestamp=datetime.datetime.utcnow(), description=f'**<:corret:522799759275196417> | `{ctx.author}` baniu o usuário `{user}`\n<:online:520795202060025866> ID: `{user.id}`**')
  55.                     embed.set_footer(text="RadioOfficial© 2018" )
  56.                     await ctx.send(embed=embed)
  57.  
  58.         @commands.command(name='kick', aliases=['expulsar'])
  59.         @commands.has_permissions(administrator=True)
  60.         @commands.guild_only()
  61.         async def kick(self, ctx, *, user: discord.Member=None):
  62.             if not ctx.author.guild_permissions.administrator:
  63.                 Embed = discord.Embed(color=COR, timestamp=datetime.datetime.utcnow(), description=f"**<:nook:518495958128918558> | {ctx.author.mention} Você não tem permissão para executar esse comando!**")
  64.                 Embed.set_footer(text="RadioOfficial© 2018")
  65.                 Embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url)
  66.                 return await ctx.send(embed=Embed)
  67.             if user is None:
  68.                 embed = discord.Embed(color=COR,
  69.                                             description=f'**<:nook:518495958128918558> Você precisa mencionar um usuário para expulsar**')
  70.                 embed.set_footer(text="RadioOfficial© 2018")
  71.                 embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url)
  72.                 await ctx.send(embed=embed)
  73.             else:
  74.                 if message.channel.id == canal:
  75.                     await ctx.guild.kick(user, reason=None)
  76.                     embed = discord.Embed(color=COR,
  77.                                             description=f'**<:corret:522799759275196417> Expulsou o usuário `{user}`\n<:online:520795202060025866> ID: `{user.id}`**')
  78.                     embed.set_footer(text="RadioOfficial© 2018")
  79.                     embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url)
  80.                     await ctx.send(embed=embed)
  81.  
  82.     @commands.command()
  83.     @commands.has_permissions(administrator=True)
  84.     async def setmod(self, ctx, *, channel: discord.TextChannel=None):
  85.         if ctx.author.bot:
  86.             Embed = discord.Embed(color=COR, description=f'**<:nook:518495958128918558> | {ctx.author.mention} Bots não podem setar**')
  87.             Embed.set_footer(text="RadioOfficial© 2018")
  88.             Embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url)
  89.             return await ctx.send(embed=Embed)
  90.         else:
  91.             pass
  92.         try:
  93.             await ctx.message.delete()
  94.             mongo = MongoClient(ulr)
  95.             radioofficial = mongo["radioofficial"]
  96.             mod = radioofficial["mod"]
  97.             canal = channel
  98.             radioofficial.mod.update_one({'server id':str(ctx.guild.id)}, {'$set': {'canal': channel.id}})
  99.             Embed = discord.Embed(color=COR, description=f'**<a:success:519184586719100940> Canal setado para punições: {channel.mention}**')
  100.             Embed.set_footer(text="RadioOfficial© 2018")
  101.             Embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url)
  102.             cleared = await ctx.send(embed=Embed)
  103.             await asyncio.sleep(5)
  104.             await cleared.delete()
  105.         except:
  106.             Embed = discord.Embed(color=COR, description=f'**<:nook:518495958128918558> Mencione o canal que será enviada as punições**')
  107.             Embed.set_footer(text="RadioOfficial© 2018")
  108.             Embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url)
  109.             await ctx.send(embed=Embed)
  110.  
  111.  
  112. def setup(client):
  113.     print("[Comando setarpuni] carregado")
  114.     client.add_cog(suge(client))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement