Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- import asyncio
- from pymongo import MongoClient
- import pymongo
- from discord.ext import commands
- bot = commands.Bot(command_prefix=['r%', 'r ', 'radio ', '%r', 'r-', 'r='], case_insensitive=True)
- tempro = []
- ulr = "mongodb://admin:251255rai@ds143163.mlab.com:43163/radioofficial"
- COR = 0xFFA500
- class suge():
- def __init__(self, bot):
- self.bot = bot
- async def on_guild_join(self, guild):
- mongo = MongoClient(ulr)
- radioofficial = mongo["radioofficial"]
- mod = radioofficial["mod"]
- a = {'Nome do servidor': str(guild.name), 'server id': str(guild.id), 'canal' : 'Nenhum canal setado'}
- radioofficial.mod.insert_one(a).inserted_id
- async def on_guild_remove(self, guild):
- mongo = MongoClient(ulr)
- radioofficial = mongo["radioofficial"]
- mod = radioofficial["mod"]
- a = {'Nome do servidor': str(guild.name)}
- radioofficial.mod.delete_one(a)
- async def on_message(self, message):
- mongo = MongoClient(ulr)
- radioofficial = mongo["radioofficial"]
- mod = radioofficial["mod"]
- ch = radioofficial.mod.find_one({'server id':str(message.guild.id)})
- canal = ch['canal']
- if message.author.bot:
- pass
- if canal == 'Nenhum canal setado':
- return
- @commands.command(name='ban', aliases=['banir'])
- @commands.has_permissions(administrator=True)
- @commands.guild_only()
- async def ban(self, ctx, *, user: discord.Member=None):
- if user is None:
- embed = discord.Embed(color=COR, description=f'**<:nook:518495958128918558> `{ctx.author}`, você precisa mencionar um usuário para banir**')
- embed.set_footer(text="RadioOfficial© 2018")
- await ctx.send(embed=embed)
- else:
- if message.channel.id == canal:
- await ctx.guild.ban(user, reason=None, delete_message_days=0)
- 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}`**')
- embed.set_footer(text="RadioOfficial© 2018" )
- await ctx.send(embed=embed)
- @commands.command(name='kick', aliases=['expulsar'])
- @commands.has_permissions(administrator=True)
- @commands.guild_only()
- async def kick(self, ctx, *, user: discord.Member=None):
- if not ctx.author.guild_permissions.administrator:
- 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!**")
- Embed.set_footer(text="RadioOfficial© 2018")
- Embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url)
- return await ctx.send(embed=Embed)
- if user is None:
- embed = discord.Embed(color=COR,
- description=f'**<:nook:518495958128918558> Você precisa mencionar um usuário para expulsar**')
- embed.set_footer(text="RadioOfficial© 2018")
- embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url)
- await ctx.send(embed=embed)
- else:
- if message.channel.id == canal:
- await ctx.guild.kick(user, reason=None)
- embed = discord.Embed(color=COR,
- description=f'**<:corret:522799759275196417> Expulsou o usuário `{user}`\n<:online:520795202060025866> ID: `{user.id}`**')
- embed.set_footer(text="RadioOfficial© 2018")
- embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url)
- await ctx.send(embed=embed)
- @commands.command()
- @commands.has_permissions(administrator=True)
- async def setmod(self, ctx, *, channel: discord.TextChannel=None):
- if ctx.author.bot:
- Embed = discord.Embed(color=COR, description=f'**<:nook:518495958128918558> | {ctx.author.mention} Bots não podem setar**')
- Embed.set_footer(text="RadioOfficial© 2018")
- Embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url)
- return await ctx.send(embed=Embed)
- else:
- pass
- try:
- await ctx.message.delete()
- mongo = MongoClient(ulr)
- radioofficial = mongo["radioofficial"]
- mod = radioofficial["mod"]
- canal = channel
- radioofficial.mod.update_one({'server id':str(ctx.guild.id)}, {'$set': {'canal': channel.id}})
- Embed = discord.Embed(color=COR, description=f'**<a:success:519184586719100940> Canal setado para punições: {channel.mention}**')
- Embed.set_footer(text="RadioOfficial© 2018")
- Embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url)
- cleared = await ctx.send(embed=Embed)
- await asyncio.sleep(5)
- await cleared.delete()
- except:
- Embed = discord.Embed(color=COR, description=f'**<:nook:518495958128918558> Mencione o canal que será enviada as punições**')
- Embed.set_footer(text="RadioOfficial© 2018")
- Embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url)
- await ctx.send(embed=Embed)
- def setup(client):
- print("[Comando setarpuni] carregado")
- client.add_cog(suge(client))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement