0.1.0 initial commit
This commit is contained in:
commit
0e07431c02
5 changed files with 105 additions and 0 deletions
26
.gitignore
vendored
Normal file
26
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
node_modules/
|
||||
__pycache__/
|
||||
**.pyc
|
||||
**.pyo
|
||||
**.egg-info
|
||||
**~
|
||||
.*.swp
|
||||
\#*\#
|
||||
.\#*
|
||||
alembic.ini
|
||||
.env
|
||||
.env.*
|
||||
.venv
|
||||
env
|
||||
venv
|
||||
venv-*/
|
||||
config/
|
||||
conf/
|
||||
config.json
|
||||
data/
|
||||
build/
|
||||
dist/
|
||||
/target
|
||||
.err
|
||||
.vscode
|
||||
/run.sh
|
||||
3
README.md
Normal file
3
README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Yusurland '26 Bot
|
||||
|
||||
Bot of the Yusurland '26 Discord server.
|
||||
17
pyproject.toml
Normal file
17
pyproject.toml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[project]
|
||||
name = "sakuragasaki46_yus26b"
|
||||
authors = [ { name = "Sakuragasaki46" } ]
|
||||
dynamic = [ "version" ]
|
||||
requires-python = ">=3.10"
|
||||
classifiers = [
|
||||
"Private :: X"
|
||||
]
|
||||
dependencies = [
|
||||
"py-cord>=2.7.0",
|
||||
"suou>=0.11.0",
|
||||
"python-dotenv>=1.1.0"
|
||||
]
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
version = { attr = "yus26b.__version__" }
|
||||
|
||||
55
src/yus26b/__init__.py
Normal file
55
src/yus26b/__init__.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
from suou import ConfigValue, ConfigOptions
|
||||
import dotenv
|
||||
import discord
|
||||
import logging
|
||||
import argparse
|
||||
|
||||
__version__ = "0.1.0"
|
||||
|
||||
dotenv.load_dotenv()
|
||||
|
||||
class AppConfig(ConfigOptions):
|
||||
token = ConfigValue(required=True)
|
||||
client_id = ConfigValue(required=True)
|
||||
|
||||
app_config = AppConfig()
|
||||
|
||||
# TODO make it configurable
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
bot = discord.Bot()
|
||||
|
||||
bot.auto_sync_commands = False
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
logger.info(f"Logged in as {bot.user}")
|
||||
|
||||
@bot.slash_command(
|
||||
name = "version",
|
||||
description = "Print bot's version."
|
||||
)
|
||||
async def version(ctx: discord.ApplicationContext):
|
||||
await ctx.respond(
|
||||
f"""
|
||||
* **Bot Version**: {__version__}
|
||||
* **Pycord Version**: {discord.__version__}
|
||||
""".strip()
|
||||
)
|
||||
|
||||
def make_parser():
|
||||
parser = argparse.ArgumentParser(description = "Yusurland '26's bot")
|
||||
parser.add_argument('-v', '--version', action = 'version', version = __version__)
|
||||
parser.add_argument('-s', '--sync', action='store_true', help="sync bot commands")
|
||||
return parser
|
||||
|
||||
def main():
|
||||
args = make_parser().parse_args()
|
||||
|
||||
if args.sync:
|
||||
logger.info('Syncing bot commands')
|
||||
bot.auto_sync_commands = True
|
||||
|
||||
bot.run(app_config.token)
|
||||
4
src/yus26b/__main__.py
Normal file
4
src/yus26b/__main__.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
from . import main
|
||||
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue