import discord from discord.ext.commands import Bot from discord.ext import commands import asyncio import time import random import os client = commands.Bot(command_prefix = '-') client.remove_command('help') token = "NDY0OTgwMjc4MjA5OTM3NDEw.Dy-1tQ.LF-W7KiD5izBNpz2dScr-63qF6o" hello_chat = ["HELLO", "HI"] chat_filter = ["FUCK", "SHIT", "BITCH", "NIGGA"] bypass_list = [] reddit = praw.Reddit(client_id='464980278209937410', client_secret='nh3DJXemAb4uIRqkL00IBf8bU_hTtLvY', user_agent='USER_AGENT HERE') @client.event #Print out text in the terminal when the bot run async def on_ready(): print('Bot Name:') print(client.user.name) print('------------------') print('Bot ID:') print(client.user.id) print('------------------') print('Discord Version:') print(discord.__version__) print('------------------') await client.send_message(client.get_channel('454421497113477146'), "I'm online! :white_check_mark:") @client.event async def on_member_join(member): embed = discord.Embed( colour = discord.Colour.blue()) embed.add_field(name='Welcome to **Volt Bot Server**', value='---------', inline=False) embed.add_field(name='Please read the rules!', value='---------', inline=False) embed.set_footer(text="Created by Hydra#8162") await client.send_message(member, embed=embed) role = discord.utils.get(member.server.roles, name="Members") await client.add_roles(member, role) print("Added role '" + role.name + "' to " + member.name) @client.command() async def ping(): await client.say("Pong! :ping_pong:") @client.command(pass_context=True) async def coinflip(ctx): messages = ["Head!", "Tail!"] await client.send_message(ctx.message.channel, random.choice(messages)) @client.command(pass_context=True) async def oracle(ctx): messages = ["Certainly", "I don't think so", "My sources said yes", "My sources said no", "Yes, just yes", "No, just no", "Hell yes", "Hell no"] await client.send_message(ctx.message.channel, random.choice(messages)) @client.event async def on_message(message): await client.process_commands(message) if message.content.upper().startswith('-SCREAM'): #Being able to talk as the bot in announcement if message.author.id == "300912784097411072": args = message.content.split(" ") await client.send_message(client.get_channel('454553459451101186'), "%s" % (" ".join(args[1:]))) else: await client.send_message(message.channel, "You do not have permission") if message.content.upper().startswith('-SAY'): #Being able to talk as the bot in chat if message.author.id == "300912784097411072": args = message.content.split(" ") await client.send_message(client.get_channel('454421497113477146'), "%s" % (" ".join(args[1:]))) else: await client.send_message(message.channel, "You do not have permission") if message.content.upper() in chat_filter: userID = message.author.id await client.delete_message(message) await client.send_message(message.channel, "<@%s> You're not allowed to say that here! :x:" % (userID)) if message.content.upper().startswith('-SERVER'): await client.send_message(message.channel, "Here is the link :ok_hand: https://discord.gg/n6ZXwEq") if message.content.upper() in hello_chat: userID = message.author.id await client.send_message(message.channel, " Hi <@%s>! :wave:" % (userID)) @client.command(pass_context=True) #Help command async def help(ctx): author = ctx.message.author embed = discord.Embed( colour = discord.Colour.blue()) embed.set_author(name='Commands') embed.add_field(name='-help', value='Send you a list of commmands.', inline=False) embed.add_field(name='-server', value='Send you the link of the server.', inline=False) embed.add_field(name='-ping', value='Ping pong! :ping_pong:', inline=False) embed.add_field(name='-oracle (question)', value='The oracle speaks the truth, she will answer you**truthfully**.', inline=False) embed.add_field(name='-coin', value='Head or Tail, this command does the trick.', inline=False) embed.add_field(name='-moderation', value='Send you a list of commands that is available for moderators.', inline=False) embed.set_footer(text="Created by Hydra#8162") await client.send_message(author, embed=embed) @client.command(pass_context=True) #Moderator help command async def moderation(ctx): author = ctx.message.author embed = discord.Embed( colour = discord.Colour.blue()) embed.set_author(name='Moderation Commands') embed.add_field(name='-clear (number)', value='Clear a certain amount of text.', inline=False) embed.add_field(name='-kick (username)', value='Kick a user.', inline=False) embed.add_field(name='-ban (username)', value='Ban a user.', inline=False) embed.add_field(name='-unban (username)', value='Unban a user.', inline=False) embed.add_field(name='-banlist (username)', value='Show a list of banned members.', inline=False) embed.set_footer(text="Created by Hydra#8162") await client.send_message(author, embed=embed) @client.command(pass_context=True) #Ban command @commands.has_permissions(ban_members=True) async def ban(ctx,user:discord.Member): if user.server_permissions.ban_members: await client.say("**I can't ban a staff member!**") return try: await client.ban(user) await client.say(user.name+' was banned. Good bye '+user.name+'! :wave:') except discord.Forbidden: await client.say('Permission denied.') return except discord.HTTPException: await client.say('ban failed.') return @client.command(pass_context = True) #Ban list @commands.has_permissions(administrator=True) async def banlist(ctx): x = await client.get_bans(ctx.message.server) x = '\n'.join([y.name for y in x]) embed = discord.Embed(title = "Banned List", description = x, color = 0xFFFFF) return await client.say(embed = embed) @client.command(pass_context=True) #Kick command @commands.has_permissions(kick_members=True) async def kick(ctx,user:discord.Member): if user.server_permissions.kick_members: await client.say("**I can't kick a staff member!**") return try: await client.kick(user) await client.say(user.name+' was kicked. Good bye '+user.name+'! :wave:') await client.delete_message(ctx.message) except discord.Forbidden: await client.say('Permission denied.') return @client.command(pass_context=True) @commands.has_permissions(ban_members=True) async def unban(ctx): ban_list = await client.get_bans(ctx.message.server) # Show banned users await client.say("Ban list:\n{}".format("\n".join([user.name for user in ban_list]))) # Unban last banned user if not ban_list: await client.say('Ban list is empty.') return try: await client.unban(ctx.message.server, ban_list[-1]) await client.say('Unbanned user:{}'.format(ban_list[-1].name)) except discord.Forbidden: await client.say('Permission denied.') return except discord.HTTPException: await client.say('unban failed.') return @client.command(pass_context=True) #Clear command async def clear(ctx, amount=100): channel = ctx.message.channel messages = [] async for message in client.logs_from(channel, limit=int(amount) + 1): messages.append(message) await client.delete_messages(messages) await client.say('Messages deleted.') client.run(token)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question