fix bugs to 2.7.1
This commit is contained in:
1 parent
6747dbacb8
commit
7716f8c297
22 files changed
+639
-1018
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
import db
|
||||
from game import signin
|
||||
|
||||
DEFAULT_EMOJI = "🪙"
|
||||
|
||||
|
||||
class Signin(commands.Cog):
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message: discord.Message):
|
||||
if message.author.bot or not message.guild:
|
||||
return
|
||||
|
||||
setting = db.get_server(message.guild.id)
|
||||
emoji = setting["signin_emoji"] if setting else DEFAULT_EMOJI
|
||||
channel_id = setting["signin_channel"] if setting else None
|
||||
|
||||
if message.content.strip() != emoji:
|
||||
return
|
||||
if channel_id is not None and message.channel.id != channel_id:
|
||||
return
|
||||
|
||||
signed, jackpot = signin.try_signin(message.author.id)
|
||||
if not signed:
|
||||
return
|
||||
|
||||
try:
|
||||
await message.add_reaction(emoji)
|
||||
except discord.HTTPException:
|
||||
pass # 表符失效(例如被刪除)時不影響簽到
|
||||
|
||||
if jackpot:
|
||||
await message.channel.send(
|
||||
f"# 感謝 {message.author.mention} 的陪伴!\n"
|
||||
f"將為您奉上三顆糾纏之緣 (共 {signin.JACKPOT_COIN} 代幣)!\n"
|
||||
"# 🏆 達成成就《三顆糾纏之緣》"
|
||||
)
|
||||
|
||||
|
||||
async def setup(bot: commands.Bot):
|
||||
await bot.add_cog(Signin(bot))
|
||||
Reference in new issue
Block a user