-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdicebot.py
More file actions
55 lines (41 loc) · 1.43 KB
/
dicebot.py
File metadata and controls
55 lines (41 loc) · 1.43 KB
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
import discord
from discord.ext import commands
import asyncio
import os.path
from os import path
from gamemode import GameMode
token = ""
command_prefix = ""
extensions = ["cogs.roll", "cogs.reference", "cogs.utility"]
def load_user_info():
global token
global command_prefix
with open("docs/user.info", 'r') as user_info:
lines = user_info.read().splitlines()
token = lines[0]
command_prefix = lines[1]
bot = commands.Bot(command_prefix="!")
if __name__ == '__main__':
if path.exists("docs/user.info"):
print("User info exists; starting bot...")
load_user_info()
else:
print("User info not found; prompting for info...")
token = input("Enter your bot's token: ")
command_prefix = input("Enter your bot's command prefix: ")
with open("docs/user.info", 'w') as user_file:
user_file.write(token + "\n")
user_file.write(command_prefix)
load_user_info()
bot.command_prefix = command_prefix
bot.remove_command("help")
for extension in extensions:
bot.load_extension(extension)
bot.current_gamemode = GameMode.WIZARDS_FIFTH_ED
@bot.event
async def on_ready():
print("Let's Roll!")
print(bot.user.name)
print(bot.user.id)
await bot.change_presence(activity=discord.Game(name='D&D 5th Edition | ' + bot.command_prefix + 'help'))
bot.run(token, bot=True, reconnect=True)