SHARE
TWEET

Untitled

a guest Oct 18th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import discord
  3. from discord.ext import commands
  4. import random
  5. from discord.utils import get
  6. import youtube_dl
  7. import os
  8. import shutil
  9. from os import system
  10. from discord import Member
  11. from discord.ext.commands import has_permissions, MissingPermissions, MissingRole
  12. import unicodedata
  13. import io
  14. import textwrap
  15. from pprint import pprint
  16. from tabulate import tabulate
  17. import traceback
  18. from contextlib import redirect_stdout
  19. from discord import Colour
  20.  
  21.  
  22.  
  23. client = commands.Bot(command_prefix = '.')
  24. client.remove_command('help')
  25.  
  26.  
  27.  
  28. @client.event
  29. async def on_ready():
  30.     print("Logged in as : " + client.user.name + "\n")
  31.  
  32.  
  33.  
  34. @client.command()
  35. @has_permissions(manage_roles=True)
  36. async def clear(ctx, amount=10):
  37.     await ctx.channel.purge(limit=amount)
  38.     await ctx.send("Cleared chat.")
  39.  
  40.  
  41.  
  42. @clear.error
  43. async def clear_error(ctx, error):
  44.     if isinstance(error, MissingPermissions):
  45.         await ctx.send(f"Sorry {member.mention}, you do not have permissions to do that!")
  46.  
  47.  
  48.  
  49. @client.command()
  50. @has_permissions(kick_members=True)
  51. async def kick(ctx, member : discord.Member, *, reason=None):
  52.     await member.kick(reason=reason)
  53.     await ctx.send(f'Kicked {member.mention}!')
  54.  
  55.  
  56.  
  57. @kick.error
  58. async def kick_error(ctx, error):
  59.     if isinstance(error, MissingPermissions):
  60.         await ctx.send(f"Sorry {member.mention}, you do not have permissions to do that!")
  61.  
  62.  
  63. @client.command()
  64. @has_permissions(ban_members=True)
  65. async def ban(ctx, member : discord.Member, *, reason=None):
  66.     await member.ban(reason=None)
  67.     await ctx.send(f'Banned {member.mention}!')
  68.  
  69.  
  70.  
  71. @ban.error
  72. async def ban_error(ctx, error):
  73.     if isinstance(error, MissingPermissions):
  74.         await ctx.send(f"Sorry {member.mention}, you do not have permissions to do that!")
  75.  
  76.  
  77. @client.command()
  78. @has_permissions(ban_members=True)
  79. async def unban(ctx, *, member):
  80.  
  81.     banned_users = await ctx.guild.bans()
  82.  
  83.     for ban_entry in banned_users:
  84.  
  85.         user = ban_entry.user
  86.  
  87.         await ctx.guild.unban(user)
  88.  
  89.         await ctx.send(f'`Unbanned user!`')
  90.  
  91.  
  92.  
  93. @unban.error
  94. async def unban_error(ctx, error):
  95.         if isinstance(error, MissingPermissions):
  96.             await ctx.send(f"Sorry {member.mention}, you do not have permissions to do that!")
  97.  
  98.  
  99. @client.command()
  100. @has_permissions(manage_server=True)
  101. async def help(ctx):
  102.     embed = discord.Embed(description='**> Moderation + Commands**', color=0x0071c4)
  103.     embed.add_field(name='Userinfo',value = 'Gives info about a user.', inline=False)
  104.     embed.add_field(name='Clear',value = 'Clears a channel', inline=False)
  105.     embed.add_field(name='Kick',value = 'Kicks a member.', inline=False)
  106.     embed.add_field(name='Ban',value = 'Bans a member.', inline=False)
  107.     embed.add_field(name='Unban',value = 'Unbans a member.', inline=False)
  108.     embed.add_field(name='Mute',value = 'Mutes a member, (mute + member tag)', inline=False)
  109.     embed.add_field(name='Unmute',value = 'Unmutes a member, (unmute + member tag), use if muted.', inline=False)
  110.     await ctx.author.send(embed=embed)
  111.     await ctx.send('```A message containing all commands has been sent do your dm!```')
  112.  
  113.  
  114.  
  115. @help.error
  116. async def help_error(ctx, error):
  117.     if isinstance(error, MissingPermissions):
  118.         await ctx.send(f"Sorry {member.mention}, you do not have permissions to do this!")
  119.  
  120.  
  121.  
  122. @client.command()
  123. @has_permissions(manage_server=True)
  124. async def userinfo(ctx, member: discord.Member):
  125.  
  126.     roles = [role for role in member.roles]
  127.  
  128.     embed = discord.Embed(colour=member.color, timestamp=ctx.message.created_at)
  129.  
  130.     embed.set_author(name=f"User Info = {member}")
  131.     embed.set_thumbnail(url=member.avatar_url)
  132.     embed.set_footer(text=f"Request by {ctx.author}", icon_url=ctx.author.avatar_url)
  133.  
  134.     embed.add_field(name="ID:", value=member.id)
  135.     embed.add_field(name="Username:", value=member.display_name)
  136.  
  137.     embed.add_field(name="Created:", value=member.created_at.strftime("%a, %d %B %Y, %I:%M %p UTC"))
  138.     embed.add_field(name="Joined At:", value=member.joined_at.strftime("%a, %d %B %Y, %I:%M %p UTC"))
  139.  
  140.     embed.add_field(name=f"Roles ({len(roles)})", value=" ".join([role.mention for role in roles]))
  141.     embed.add_field(name="Highest Role:", value=member.top_role.mention)
  142.  
  143.  
  144.     await ctx.send(embed=embed)
  145.  
  146.  
  147.  
  148. @userinfo.error
  149. async def userinfo_error(ctx, error):
  150.     if isinstance(error, MissingPermissions):
  151.         await ctx.send(f"Sorry {member.mention}, you do not have permissions to do this!")
  152.  
  153.  
  154. @client.command()
  155. @has_permissions(manage_roles=True)
  156. async def mute(ctx, member: discord.Member):
  157.     role = discord.utils.get(ctx.guild.roles, name="muted")
  158.     await member.add_roles(role)
  159.     await ctx.send(f"**Muted {member.mention}**")
  160.     await ctx.author.send('You have been muted.')
  161.  
  162.  
  163.  
  164. @mute.error
  165. async def mute_error(ctx, error):
  166.     if isinstance(error, MissingPermissions):
  167.         await ctx.send(f"Sorry {member.mention}, you do not have permissions to do that!")
  168.  
  169.  
  170.  
  171. @client.command()
  172. @has_permissions(manage_roles=True)
  173. async def unmute(ctx, member: discord.Member):
  174.     role = discord.utils.get(ctx.guild.roles, name="muted")
  175.     await member.remove_roles(role)
  176.     await ctx.send(f"**Unmuted {member.mention}**")
  177.     await ctx.author.send('You have been unmuted.')
  178.  
  179.  
  180.  
  181. @unmute.error
  182. async def unmute_error(ctx, error):
  183.     if isinstance(error, MissingPermissions):
  184.         await ctx.send(f"Sorry {member.mention}, you do not have  permissions to do that!")
  185.  
  186.  
  187.  
  188. client.run('')
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