-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (38 loc) · 1.41 KB
/
main.py
File metadata and controls
53 lines (38 loc) · 1.41 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
53
"""
Main bot file for Secret Hitler discord bot.
Runs bot and loads in commands.
"""
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='', #Prefixless
intents=intents,
owner_id=251092222831755264,
case_insensitive=True,
help_command=None
)
bot.load_extension('commands') #Command extension that handles cogs
games = bot.get_cog('GameCommands') #For seeing who can use commands
def useropen(user): #Seeing if someone can use commands
game = games._get_game(user)
if not(game):
return True
return game._get_player(user).open
@bot.event
async def on_message(message):
if not(isinstance(message.channel, discord.DMChannel)) or message.author.bot: #Only users in DMs
return
if not(useropen(message.author)): #Currently replying to bot in game
return
await bot.process_commands(message) #Process commands normally through bot class
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send(error.args[0] + '.') #Error message passed (Command "command" is not found)
return
if isinstance(error, commands.NotOwner):
await ctx.send('You cannot use this command.')
return
raise error
bot.run(open('token.txt').read())