-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTildaBot.py
117 lines (99 loc) · 3.38 KB
/
TildaBot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import discord, datetime, random, os
from discord.ext.commands import Bot
from datetime import datetime as dt
bot_name = "TildaBot"
client = discord.Client()
bot = Bot(command_prefix="!")
current_time = dt.now().strftime('%H:%M:%S')
current_date = dt.now().strftime('%Y-%m-%d')
token_file = open("user_token.txt")
user_token = token_file.read()
tilda_dev = discord.Object(id="299224095365529600")
tilda_null = discord.Object(id="299225312410075136")
# Tilda-dev 299224095365529600
# Tilda-null 299225312410075136
# Test channel 299220779047059456
# Events
@bot.event # Boot
async def on_ready():
print("Online".format(bot_name))
await bot.send_message(tilda_null,"Up and running")
#return await bot.say("Up and running!")
# @bot.event # Reboot command used as event
# async def on_message(message, *args):
# if str(args) == "()":
# if message.channel == discord.utils.get(message.server.channels, name="tilda-null"):
# if message.content.startswith("$reboot"):
# #await discord.Client(delete_message(message))
# await bot.send_message(tilda_null, "Rebooting...")
# print("Rebooting...")
# os.system("start reboot.py")
# import sys; sys.exit()
# if message.content.startswith("!hello"):
# await bot.send_message(tilda_null, "Hello, world!")
# else:
# if message.content.startswith("!hello"):
# await bot.send_message(tilda_null, "Hello, {}!".format(*args))
# Commands
@bot.command()
async def reboot(*args):
"""Reboot the bot"""
await bot.say("Rebooting...")
os.system("start reboot.py")
import sys; sys.exit()
# Ping
@bot.command()
async def ping(*args):
"""Pong!"""
return await bot.say("Pong!")
# Echo
@bot.command()
async def echo(*args):
"""Repeats the text you say"""
say_this = ""
for i in args:
say_this += i + " "
return await bot.say(say_this)
# Time and date
@bot.command()
async def time():
"""Current time and date (UTM+2 only atm)"""
return await bot.say("The time is: {}\nThe date is: {}"\
.format(current_time,current_date))
# Roll the dice - Add sides options
@bot.command(description="Use !roll for a single dice and !roll x for more")
async def roll(*args):
"""Roll the dice"""
rand_numbers = []
if str(args) == "()":
rand_numbers.append(random.randint(1,6))
elif not int(*args) >= 6:
for i in range(int(*args)):
rand_numbers.append(random.randint(1,6))
else:
for i in range(6):
rand_numbers.append(random.randint(1,6))
numbers = "".join(str(rand_numbers))
return await bot.say("You rolled: {}".format(numbers[1:-1]))
# Cool
@bot.group(pass_context=True)
async def cool(ctx):
"""Says if a user is cool.
In reality this just checks if a subcommand is being invoked.
"""
if ctx.invoked_subcommand is None:
await bot.say('No, {0.subcommand_passed} is not cool'.format(ctx))
@cool.command(name='bot')
async def _bot():
"""Is the bot cool?"""
await bot.say('Yes, the bot is cool.')
# You're right
@bot.command()
async def amiright():
"""Check if you're right"""
return await bot.say("You're totally right.")
print("amiright")
os.system("cls")
print("Starting")
bot.run(user_token)
#https://discordapp.com/oauth2/authorize?client_id=YOUR_ID_HERE&scope=bot&permissions=0