Skip to content

Commit

Permalink
Minor formatting fixups with black
Browse files Browse the repository at this point in the history
  • Loading branch information
freiheit committed Oct 29, 2023
1 parent 784bd66 commit 7221291
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions mvkdicebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,55 @@
import asyncio
import discord
import logging
import random
import os
import random
import re
import warnings

from configparser import ConfigParser
from discord.ext import commands

__version__ = "0.0.1"
description = '''A dice rolling bot for MvK
'''
description = """A dice rolling bot for MvK
"""

intents = discord.Intents.default()
#intents.members = True
#intents.messages = True
# intents.members = True
# intents.messages = True
intents.message_content = True

bot = commands.AutoShardedBot(
command_prefix=commands.when_mentioned_or('?'),
command_prefix=commands.when_mentioned_or("?"),
description=description,
intents=intents)
intents=intents,
)

config, logger = get_config()


@bot.event
async def on_ready():
logger.info(f'Logged in as {bot.user} (ID: {bot.user.id})')
logger.info(f"Logged in as {bot.user} (ID: {bot.user.id})")


@bot.hybrid_command()
async def roll(ctx, dice: str):
"""Rolls a dice in NdN format."""
"""Rolls a pool of dice in NdN format. Example: '?roll 1d20 2d10 d8 2d6'"""
# self.logger
try:
rolls, limit = map(int, dice.split('d'))
rolls, limit = map(int, dice.split("d"))
except Exception:
await ctx.send('Format has to be in NdN!')
await ctx.send("Format has to be in NdN!")
return

result = ', '.join(str(random.randint(1, limit)) for r in range(rolls))
result = ", ".join(str(random.randint(1, limit)) for r in range(rolls))
await ctx.send(result)


class ImproperlyConfigured(Exception):
pass


BASE_DIR = os.path.dirname(os.path.abspath(__file__))
HOME_DIR = os.path.expanduser("~")

Expand All @@ -71,6 +79,7 @@ class ImproperlyConfigured(Exception):
os.path.join("mvkdicebot.ini"),
]


def get_config():
config = ConfigParser()
config_paths = []
Expand Down Expand Up @@ -103,10 +112,9 @@ def get_config():

return config, logger

config, logger = get_config()

bot.run(
token=config["MAIN"].get("authtoken"),
reconnect=True,
log_level=logger.getEffectiveLevel()
)
token=config["MAIN"].get("authtoken"),
reconnect=True,
log_level=logger.getEffectiveLevel(),
)

0 comments on commit 7221291

Please sign in to comment.