discordBot/OLD/bot.py
2019-04-08 21:30:51 -05:00

177 lines
5.7 KiB
Python
Executable File

from discord.ext.commands import Bot
import discord
import random
import math
# version 1.0
prefix = 'o!'
token = "NTAxNDg1OTA2ODAxNDU5MjAw.DqaHWQ.MZ_B52xFTKyffRJ9pmMiYLVHYhM"
client = Bot(command_prefix=prefix)
client.remove_command("help")
ouat_bypass = open("Data/ouat_bypass.txt", 'r')
@client.command(name='8ball',
description='Answers a yes or no question',
brief="Its an 8ball",
aliases=['eight_ball', 'eightball', '8bal'],
pass_context=True)
async def eight_ball(context):
possible_responses = [
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
'Na man your gay'
]
await client.say(random.choice(possible_responses) + ", " + context.message.author.mention)
@client.command(name='Add',
description='Adds two real numbers',
brief="MATHS",
aliases=['add', '+'],
pass_context=True)
async def add(context, number, second_number):
added = float(number) + float(second_number)
await client.say(
context.message.author.mention +
' ' +
str(number) +
" + " +
str(second_number) +
" is " +
str(added))
@client.command(name='Square root',
description='Squares a real number',
brief='Hard MATHS',
aliases=['squareroot', 'square_root', 'sqrt'],
pass_context=True)
async def sqrt(context, number):
squared = math.sqrt(float(number))
await client.say(context.message.author.mention +
', ' +
str(number) +
" Squared is " +
str(squared))
@client.command(pass_context=True)
async def rules_update(ctx):
if ctx.message.author.id == '305589587215122432':
rules = open("Data/Rules", 'r')
await client.purge_from(client.get_channel("501176716962824212"))
await client.send_message(client.get_channel("501176716962824212"), rules.read())
else:
await client.say("Incorrect permission, If you believe this is a mistake please contact bot developer")
@client.command(pass_context=True)
async def rules_add(ctx, new_rule):
if ctx.message.author.id == '305589587215122432':
rules = open("Data/Rules", 'a')
rules.write('\n')
rules.write('\n')
rules.write(new_rule)
else:
await client.say("Incorrect permission, If you believe this is a mistake please contact bot developer")
@client.command(pass_context=True)
async def help(ctx):
author = ctx.message.author
embed = discord.Embed(
colour=discord.Colour.green()
)
embed.set_author(name="help")
embed.add_field(name="eight_ball", value="Answers a question ~ Usage - !8ball", inline=False)
embed.add_field(name="Add", value="Adds two real numbers ~ Usage - !add NUMBER NUMBER", inline=False)
embed.add_field(name="Square root", value="Squares a real number ~ Usage - !sqrt NUMBER", inline=False)
await client.send_message(author, embed=embed)
@client.event
async def on_message(message):
if message.channel.id == "507386320604102696":
temp = 0
temp2 = 0
contents = message.content.split()
string_contents = ''.join(contents)
temp_contents = message.content.split('.')
n = len(string_contents)
y = 0
try:
for k in range(n):
x = (string_contents[k])
y = y + 1
if x == '.':
temp = temp + 1
if ((len(contents) >= 3) or (len(temp_contents) >= 3)) and (temp > 1) and (temp2 == 0):
await client.delete_message(message)
temp2 = 1
else:
if (not(x == '.') and(y == n)) or (temp >= 2) and (temp2 == 0):
await client.delete_message(message)
temp2 = 1
except:
# this is here to do nothing
return True
await client.process_commands(message)
client.run(token)