Skip to content

Commit

Permalink
MEE6レベルアップ、自動送信機能追加v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Syunngiku0402 committed Nov 3, 2024
1 parent b6ef975 commit d7c3ec1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
33 changes: 33 additions & 0 deletions cogs/cmee6level.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from discord.ext import commands
import discord
from config.config import config


class CMee6level(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot

@commands.Cog.listener("on_message")
async def on_message(self, message: discord.Message):
if "mee6level" in message.content.startswith:
if message.channel.id in [config.mee6.botch]: # 非公開mee6-level通知チャンネル
userid = message.content.split(",")[1] # userid表示
username = message.content.split(",")[2] # user名表示
level = message.content.split(",")[3] # レベル
if (level % 50 == 0):
text = "# "
elif (level % 10 == 0):
text = "## "
elif (level % 5 == 0):
text = "### "
else:
text = ""
mee6_channel = await self.bot.fetch_channel(config.mee6.levelup) # 新たに作るmee6通知チャンネル
if message.author.roles in [config.mee6.levelupnoticeoff]: # mee6levelup無効化ロールを持っているかどうか
await mee6_channel.send(f"{text}/xp reached {username} level {level}")
else:
await mee6_channel.send(f"{text}/xp reached <@{userid}> level {level}")


async def setup(bot: commands.Bot):
await bot.add_cog(CMee6level(bot))
7 changes: 7 additions & 0 deletions config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ class YChannel(BaseModel):
admin_channel_id: int


class MEe6(BaseModel):
botch: int
levelup: int
levelupnoticeoff: int


class Config(BaseModel):
token: str
guild_id: int
Expand All @@ -31,6 +37,7 @@ class Config(BaseModel):
y_channel: int
cmdbot_log: int
lottery_channel: int
mee6: MEe6

# -----------------------------------------------------------

Expand Down

0 comments on commit d7c3ec1

Please sign in to comment.