Esempio n. 1
0
 async def blre(self, ctx, member: int):
     '''從黑名單移除 <對方id>'''
     try:
         yamlhook("config.yaml").operate(member,
                                         db="blacklist",
                                         process="remove")
         # 輸出移除成功
         await ctx.send(f"> ✅`{member}`已從黑名單移除!")
     except ValueError:  # 找不到ID
         error = "找不到對方資料。"
         await error_process(ctx, error, process="custom")
Esempio n. 2
0
 async def cpcadd(self,ctx,member:discord.Member):
     '''增加自訂權限者'''
     ydata = yamlhook("config.yaml").load()
     if ctx.author.id in ydata['bot']['owner']: # 檢查一次,防止有兩個同樣的ID存在
         did = member.id
         yamlhook("config.yaml").owner(did,process="append")
         # 輸出增加成功
         await ctx.send(f"> ✅自訂權限者`{member.display_name}`已增加!")
     else:
         error = "對方已在自訂權限名單內。"
         await error_process(self,ctx,error,process="custom")
Esempio n. 3
0
 async def cpcre(self,ctx,member:discord.Member):
     '''移除自訂權限者'''
     ydata = yamlhook("config.yaml").load()
     try:
         if ctx.author.id in ydata['bot']['owner']:
             did = member.id
             yamlhook("config.yaml").owner(did,process="remove")
             # 輸出移除成功
             await ctx.send(f"> ✅自訂權限者`{member.display_name}`已移除!")
     except ValueError:
         error = "找不到對方資料。"
         await error_process(self,ctx,error,process="custom")         
Esempio n. 4
0
 async def bladd(self, ctx, member: int):
     '''增加至黑名單 <對方id>'''
     ydata = yamlhook("config.yaml").load()
     if member not in ydata['blacklist']:  # 檢查一次,防止有兩個同樣的ID存在
         yamlhook("config.yaml").operate(member,
                                         db="blacklist",
                                         process="append")
         # 輸出增加成功
         await ctx.send(f"> > ✅`{member}`已增加到黑名單!")
     else:
         error = "已增加到黑名單。"
         await error_process(ctx, error, process="custom")
Esempio n. 5
0
 def predicate(ctx):
     try:
         ydata = yamlhook("config.yaml").load()
         if ctx.author.id not in ydata['bot']['owner']:
             return False
         else:
             return True
     except TypeError:
         raise TypeError('Sorry but I can`t find anyone in list.')
     except FileNotFoundError:
         raise FileNotFoundError('Sorry but I can`t find the config file.')
Esempio n. 6
0
import discord
from discord.ext import commands
from core.datahook import yamlhook
import os

bot = commands.Bot(command_prefix="dcb.")


@bot.event
async def on_ready():
    await bot.change_presence(activity=discord.Game(name="dcb.help."))
    print("[DCB] Bot is on!")


# 裝載Cog
for filename in os.listdir('./cmds'):
    if filename.endswith('.py'):
        bot.load_extension(f'cmds.{filename[:-3]}')

if __name__ == "__main__":
    # console 訊息清除
    # windows        : os.system("cls")
    # linux or other : os.system("clear")
    os.system("cls")
    # 抓取 bot token
    ydata = yamlhook("config.yaml").load()
    bot.run(ydata['bot']['token'])
Esempio n. 7
0
 async def on_member_join(self, member):
     # 被動Ban掉黑名單內的指定用戶
     ydata = yamlhook("config.yaml").load()
     if member.id in ydata['blacklist']:
         await member.kick(reason=None)
         print(f"[T91] Detected {member}! has been kicked!")
Esempio n. 8
0
 async def blist(self, ctx):
     '''瀏覽黑名單'''
     ydata = yamlhook("config.yaml").load()
     blacklist = [bm for bm in ydata['blacklist']]
     await ctx.send(f"```md\n{blacklist}\n```")