Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # server -> guild, client.add_roles -> member.add_roles, say and send_message -> ctx.send.
- # errors still don't work
- # Imports
- import discord
- from discord.utils import get
- from discord import Game
- import asyncio
- from discord.ext.commands import Bot
- from discord.ext.commands import *
- import discord.ext.commands
- import random
- # Variables
- pref = 'k!'
- client = Bot(command_prefix=pref)
- token = ''
- # Main --- Commands
- def check(author):
- def inner_check(message):
- if message.author != author:
- return False
- try:
- int(message.content)
- return True
- except ValueError:
- return False
- return inner_check
- # Fun
- @client.command(name='8ball',
- brief='Answers a question',
- pass_context=True)
- async def eightball(context):
- responses = ['That is a resounding no',
- 'It is not looking likely',
- 'Too hard to tell',
- 'It is very possible',
- 'Definitely',
- 'Try asking later',
- 'Your family are disappointed',
- 'No comment',
- 'Maybe, but Sanji is definitely Gaeji',
- 'Who cares, Bellyache is autistic',
- 'Absolutely',
- 'Probably',
- 'Not looking good',
- "I'd rather not say",
- "You don't want to know",
- 'God is telling me no, but...',
- ]
- await context.send(random.choice(responses) + ", " + context.message.author.mention)
- @client.command(name='numgame',
- brief='Guess a number between 1 and 100',
- pass_context=True)
- async def numgame(context):
- number = random.randint(1,100)
- guess = 4
- while guess != 0:
- await context.send('Pick a number between 1 and 100')
- msg = await client.wait_for('message', check=check(context.author), timeout=30)
- attempt = int(msg.content)
- if attempt > number:
- await context.send(str(guess) + ' guesses left...')
- await asyncio.sleep(1)
- await context.send('Try going lower')
- await asyncio.sleep(1)
- guess -= 1
- elif attempt < number:
- await context.send(str(guess) + ' guesses left...')
- await asyncio.sleep(1)
- await context.send('Try going higher')
- await asyncio.sleep(1)
- guess -=1
- elif attempt == number:
- await context.send('You guessed it! Good job!')
- break
- else:
- await context.send("You didn't get it")
- @client.command(name='say',
- brief='Repeats your message',
- pass_context=True)
- async def on_message(context, *, mes):
- await context.send(mes)
- await context.message.delete()
- # Moderation
- @client.command(name='kick',
- brief='Kicks user',
- aliases=['Kick'],
- pass_context=True)
- async def kick(context, member:discord.Member=None):
- # Errors
- if not member:
- await context.send('Please specify a member.')
- return
- if member not in context.guild.members():
- await context.send('Member does not exist.')
- # Actual Kicking
- if context.author.guild_permissions.kick_members == True:
- await member.kick()
- await context.send(f"{member.mention} was kicked ")
- else:
- await context.send(context.message.author.mention + ", you don't have permission")
- @client.command(name='ban',
- brief='Bans user',
- aliases=['Ban'],
- pass_context=True)
- async def ban(context, member: discord.Member, reason=None):
- if context.author.guild_permissions.ban_members == True:
- await member.ban()
- await context.send(f"{member.mention} was banned. Reason: " + reason)
- else:
- await context.send(context.message.author.mention + ", you don't have permission")
- @client.command(name='mute',
- brief='Gets rid of a pest',
- aliases=['shutup'],
- pass_context=True)
- async def mute(context, member: discord.Member):
- if context.author.guild_permissions.manage_roles == True:
- role = get(member.guild.roles, name='Muted')
- await member.add_roles(role)
- await context.send(f'{member.mention} was muted.')
- else:
- await context.send(context.message.author.mention + ", you don't have permission")
- @mute.error
- async def mute_error(context, error):
- if isinstance(error, ConversionError):
- await context.send(context.message.channel, 'Please specify a member')
- else:
- raise error
- @client.command(name='unmute',
- brief='Test your luck',
- aliases=['unshutup'],
- pass_context=True)
- async def unmute(context, member: discord.Member):
- if member == None:
- await context.send(context.message.channel, 'Please specify a member')
- return
- if context.author.guild_permissions.manage_roles == True:
- role = get(member.guild.roles, name='Muted')
- await member.remove_roles(role)
- await context.send(f'{member.mention} was unmuted.')
- else:
- await context.send(context.message.author.mention + ", you don't have permission")
- #@unmute.error
- #async def unmute_error(context, error):
- #if isinstance(error, ConversionError):
- #await context.send(context.message.channel, 'Please specify a member')
- #else:
- #raise error
- # to do
- @client.command(name='unban',
- brief='Unbans user',
- aliases=['Unban'],
- pass_context=True)
- # Main --- Events
- @client.event
- async def on_member_join(member):
- channel = 546309900335316992
- await channel.send(str(member)+" joined")
- # Logs
- # Confirmation Kiss-shot is on
- @client.event
- async def on_ready():
- game = discord.Game('Prefix = k!')
- await client.change_presence(status=discord.Status.idle, activity=game)
- print("You're logged in as " + client.user.name)
- client.run(token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement