async def agree(self, ctx): if ctx.author.id not in admin_list: conn = r.connect() pp = conn.get("maintenance") q = ['0', '3'] if pp not in q: return await ctx.send("現在、メンテナンス中です") if ctx.guild.id != main_guild_id: return c = 0 for i in ctx.author.roles: if i.name == role_name: c = 1 if c == 1: return await ctx.send("既に、認証しています。") command_time = datetime.datetime.now() command_minute = command_time.minute members = ctx.author.id # データベース読み込み(値をjtに) conn = r.connect() jt = conn.get(members) x = int(command_minute) - int(jt) if x < 0: x += 60 if x > 2: role = discord.utils.get(ctx.guild.roles, name=role_name) await ctx.author.add_roles(role) await ctx.send("認証が完了しました。") p = conn.delete(members) print(p) else: x = 3 - x await ctx.send(f"後{x}分後に認証ができます。")
async def get(self, ctx, what1): """get [key]""" if ctx.author.id != self.ahomin: return await ctx.send("貴方は使えません") conn = r.connect() p = conn.get(what1) await ctx.send(p)
async def set(self, ctx, what1, what2): """set [key] [value]""" if ctx.author.id != self.ahomin: return await ctx.send("貴方は使えません") conn = r.connect() q = conn.set(what1, what2) await ctx.send(q)
async def 通知(self, ctx): if ctx.author.id not in admin_list: conn = r.connect() pp = conn.get("maintenance") q = ['0', '3'] if pp not in q: return await ctx.send("現在、メンテナンス中です") role = discord.utils.get(ctx.guild.roles, name='メンションOK') if ctx.author.bot: return if ctx.channel.id == 708503714713043004: if role in ctx.author.roles: embed = discord.Embed( title="役職の剥奪", description=f"{ctx.author.mention}\n役職:`{role}`を剥奪しました。", color=discord.Color.dark_blue()) await ctx.channel.send(embed=embed) await ctx.author.remove_roles(role) else: embed = discord.Embed( title="役職の追加", description=f"{ctx.author.mention}\n役職:`{role}`を付与しました。", color=discord.Color.dark_blue()) await ctx.channel.send(embed=embed) await ctx.author.add_roles(role) else: embed = discord.Embed(title="エラー", description="このチャンネルでは、このコマンドは実行できません。", color=discord.Color.dark_red()) await ctx.channel.send(embed=embed)
async def on_message(self, message): if message.author.bot: return conn=r.connect() ky=conn.exists(message.author.id) if ky==0: uset=conn.set(message.author.id,'0') ch=self.bot.get_channel(logch) if uset == True: embed=discord.Embed(title="登録通知",description=f'{message.author.name}さんを登録しました',color=0x3498db) await ch.send(embed=embed) else: embed=discord.Embed(title="登録通知",description=f'{message.author.name}さんの登録に失敗しました',color=0xe74c3c) await ch.send(embed=embed) else: ps=conn.smembers("exp") pss=[pl for pl in ps] p=random.choice(pss) up=conn.get(message.author.id) up=int(up) p=int(p) up+=p upd=conn.set(message.author.id,up) ch=self.bot.get_channel(expch) if upd == True: embed=discord.Embed(title="登録通知",description=f'{message.author.name}さんに{p}exp付与しました',color=0x3498db) await ch.send(embed=embed) else: embed=discord.Embed(title="登録通知",description=f'{message.author.name}さんの付与に失敗しました',color=0xe74c3c) await ch.send(embed=embed)
async def rkey(self, ctx, what=None): if ctx.author.id in admin_list: conn_r = r.connect() ky = conn_r.keys() if what != None: k = conn_r.exists(what) if k == 0: embed = discord.Embed(title="**Key Error**", description=f'`{what}`は登録されていません') else: ky = conn_r.get(what) embed = discord.Embed(title="**Radis-Key**", description=None) embed.add_field(name=f'key:`{what}`', value=f'value:`{ky}`') return await ctx.send(embed=embed) if ky == None: des = "None" else: des = None embed = discord.Embed(title="Radis-Key", description=des) for i in ky: vl = conn_r.get(i) embed.add_field(name=f'key:`{i}`', value=f'value:`{vl}`') await ctx.send(embed=embed)
async def set(self, ctx, what=None, whats=None): conn=r.connect() kk=conn.smembers("開発管理者") k=[l for l in kk] cai=ctx.author.id cai=str(cai) if cai not in k: return await ctx.send("使用できません") rk=conn.smembers("人狼役職") kr=[l for l in rk] cai=what cai=str(cai) if cai not in kr: return await ctx.send("その役職はありません") if what==None: return await ctx.send("役職を指定して下さい") if whats==None: return await ctx.send("変更値を指定して下さい") rs=conn.set(what,whats) if rs ==True: embed=discord.Embed(title="役職変更成功",description=None) embed.add_field(name=f'**{what}**',value=f'`{whats}`') await ctx.send(embed=embed) else: embed=discord.Embed(title="役職変更失敗",description="`変更に失敗しました`") await ctx.send(embed=embed)
async def rdel(self, ctx, what=None): if ctx.author.id in admin_list: if what == None: return await ctx.send("削除Key指定エラー") conn_r = r.connect() d = conn_r.delete(what) await ctx.send(d)
async def srem(self, ctx, what1, what2): """srem [key] [value] and more""" if ctx.author.id != self.ahomin: return await ctx.send("貴方は使えません") conn = r.connect() f = conn.srem(what1, what2) await ctx.send(f)
async def alldelete(self, ctx): """flushdb""" if ctx.author.id != self.ahomin: return await ctx.send("貴方は使えません") conn = r.connect() ad = conn.flushdb() await ctx.send(ad)
async def delete(self, ctx, what): """delete [key]""" if ctx.author.id != self.ahomin: return await ctx.send("貴方は使えません") conn = r.connect() d = conn.delete(what) await ctx.send(d)
async def all_give_point(self, ctx): """集会参加ポイント""" self.givepoint = 0 c = str(ctx.author.id) conn = r.connect() sm = conn.smembers('adomin') for ad in sm: if ad == c: self.givepoint += 1 if self.givepoint == 0: return await ctx.send("貴方は操作できません。") mem=conn.smembers("scythes") for p in mem: q=ctx.guild.get_member(int(p)) for ro in q.roles: if ro.name == "集会参加": cg=conn.get(p) bp=int(cg)+150 det=conn.set(p,bp) for am in ctx.guild.members: for adf in am.roles: prole = ctx.guild.get_role(709678662961594371) if adf.name == "集会参加": await am.remove_roles(prole) await ctx.send("付与完了しました。")
async def key(self, ctx): """key""" if ctx.author.id != self.ahomin: return await ctx.send("貴方は使えません") conn = r.connect() ak = conn.keys() for k in ak: await ctx.send(f"`{k}`")
async def smembers(self, ctx, whst): """smembers [key]""" if ctx.author.id != self.ahomin: return await ctx.send("貴方は使えません") conn = r.connect() p = conn.smembers(f'{whst}') for w in p: await ctx.send(w)
async def on_member_remove(self, member): channel = self.bot.get_channel(689265615516598434) if member.guild.id == 689263691669176426: embed = discord.Embed( title="サーバーから退出", description=f"{member.mention}さんがサーバーから退出しました。", color=discord.Color.purple()) await channel.send(embed=embed) conn = r.connect() p = conn.delete(member.id)
async def point_geter(self, ctx): """ポイント登録者一覧""" P=1 conn = r.connect() sm = conn.smembers('scythes') embed = discord.Embed(title=f"**登録者**", description=None) for ad in sm: adm = self.bot.get_user(int(ad)) embed.add_field(name=f"{P}人目", value=f"`{adm}`") P+=1 await ctx.send(embed=embed)
async def on_ready(self): print('-----') print(self.user.name) print(self.user.id) print('-----') conn = r.connect() check = conn.exists('exp') if check == 0: t = conn.sadd('exp', '0') await self.change_presence(status=discord.Status.online, activity=discord.Game(name=f'経験値測定'))
async def point_admin(self, ctx): """ポイント管理者一覧""" P=1 conn = r.connect() sm = conn.smembers('adomin') embed = discord.Embed(title=f"**ポイント管理者一覧**", description=None, color=0x9b59b6) for ad in sm: adm = self.bot.get_user(int(ad)) embed.add_field(name=f"{P}人目", value=f"`{adm}`") P+=1 await ctx.send(embed=embed)
async def role(self, ctx): """役職関連""" conn=r.connect() # サブコマンドが指定されていない場合、メッセージを送信する。 if ctx.invoked_subcommand is None: jack=conn.smembers("人狼役職") jr=[j for j in jack] embed=discord.Embed(title="現在人狼役職",description=None) for i in jr: p=conn.get(i) embed.add_field(name=f'**{i}**',value=f'`{p}`') await ctx.send(embed=embed)
async def myexp(self, ctx, user=None): if user == None: user=ctx.author.id conn=r.connect() q=conn.exists(user) ui=self.bot.get_user(user) if q>0: up=conn.get(user) embed=discord.Embed(title="現在経験値",description=f'{ui.name}さんの経験値\n`{up}`',color=0x3498db) await ctx.send(embed=embed) else: embed=discord.Embed(title="現在経験値",description=f'{ui.name}さんの経験値\n`登録されていません`',color=0xe74c3c) await ctx.send(embed=embed)
async def del_global(self, ctx): """グローバルチャット登録解消""" cgi = ctx.guild.id cci = ctx.channel.id ccn = ctx.channel.name global_ch = "gloch" conn = r.connect() k = conn.keys() gi = str(cgi) ci = str(cci) count = 0 for i in k: if i == gi: count += 1 if count == 0: embed = discord.Embed(title="**エラー**", description="登録がされていない鯖です", color=0x992d22) return await ctx.send(embed=embed) elif count > 0: sm = conn.smembers(cgi) counts = 0 for ch in sm: if ch == ci: counts += 1 if counts == 0: embed = discord.Embed(title="**エラー**", description="このチャンネルは登録されていません", color=0x992d22) return await ctx.send(embed=embed) elif counts > 0: a1 = conn.srem(cgi, cci) a2 = conn.srem(global_ch, cci) if a1 == True and a2 == True: embed = discord.Embed(title="**登録解消情報**", description=None, color=0xe74c3c) embed.add_field(name="登録を解消しました", value=f"`登録チャンネル:{ccn}`") return await ctx.send(embed=embed) else: embed = discord.Embed(title="**エラー**", description="開発者に問い合わせて下さい`48`", color=0x992d22) return await ctx.send(embed=embed) else: embed = discord.Embed(title="**エラー**", description="開発者に問い合わせて下さい`51`", color=0x992d22) return await ctx.send(embed=embed)
async def temple(self, ctx): conn=r.connect() kk=conn.smembers("開発管理者") k=[l for l in kk] cai=ctx.author.id cai=str(cai) if cai not in k: return await ctx.send("使用できません") if ctx.invoked_subcommand is None: p=conn.smembers("人狼役職") p=[j for j in p] p='・'.join(p) embed=discord.Embed(title="現在設定可能役職",description=p) await ctx.send(embed=embed)
async def mainte(self, ctx, what=None): if ctx.author.id in admin_list: conn_r = r.connect() if what == None: p = conn_r.get('maintenance') return await ctx.send(f'現在のメンテナンスモード:`{p}`') if what == "reset": p = conn_r.set('maintenance', '0') return await ctx.send('通常モードに移行') mente = conn_r.set('maintenance', what) if mente == True: await ctx.send(f'メンテナンスモードを`{what}`に変更しました') else: await ctx.send('移行失敗')
async def compass_character(self, ctx, op=None): """(アタッカー,ガンナー,タンク,スプリンター)からランダムに出力""" if op == None: cc=random.choice(("アタッカー","ガンナー","タンク","スプリンター")) else: cc=op conn=r.connect() pp=conn.smembers(cc) pp=[cv for cv in pp] gg=random.choice(pp) embed = discord.Embed(title="**ランダムキャラ**",description=f"{ctx.author.mention}さんの使うキャラは") embed.add_field(name=f"**タイプ**",value=f"`{cc}`") embed.add_field(name=f"**キャラ名**",value=f"`{gg}`") await ctx.send(embed=embed)
async def delete(self, ctx, what=None): conn=r.connect() kk=conn.smembers("開発管理者") k=[l for l in kk] cai=ctx.author.id cai=str(cai) if cai not in k: return await ctx.send("使用できません") if what==None: return await ctx.send("役職を指定して下さい") p=conn.srem("人狼役職",what) if p ==True: embed=discord.Embed(title="役職削除成功",description=f"`{what}`") await ctx.send(embed=embed) else: embed=discord.Embed(title="役職削除失敗",description="`変更に失敗しました`") await ctx.send(embed=embed)
async def get_point(self, ctx, user_id:int= None): """ポイントの確認""" conn=r.connect() ci = str(ctx.author.id) gu = self.bot.get_user(user_id) ui = str(user_id) if user_id == None: embed = discord.Embed(title=f"**{ctx.author.name}さんの情報**", description=None) up = conn.get(ci) embed.add_field(name="現在ポイント", value=f"`{up}p`") await ctx.send(embed=embed) return else: embed = discord.Embed(title=f"**{gu.name}さんの情報**", description=None) up = conn.get(ui) embed.add_field(name="現在ポイント", value=f"`{up}p`") await ctx.send(embed=embed) return
async def sighin(self, ctx): """ポイント制度登録""" self.namebea = 0 conn = r.connect() k = conn.keys() cai = str(ctx.author.id) for i in k: if i == cai: self.namebea += 1 if self.namebea == 0: nb = conn.set(cai,"150") nb2 = conn.sadd("scythes",cai) if nb == True: await ctx.send("登録しました。\n登録特典で100Point付与しました。") else: await ctx.send("登録に失敗しました。\nやり直して下さい。") else: await ctx.send("既に登録済みです。")
async def _player(self, ctx): """確認""" conn=r.connect() kk=conn.smembers("開発管理者") k=[l for l in kk] cai=ctx.author.id cai=str(cai) if cai not in k: return await ctx.send("使用できません") pp=conn.smembers("人狼参加者") p=[j for j in pp] p.remove("0") m=1 embed=discord.Embed(title="参加者一覧",description=None) for i in p: player=self.bot.get_user(int(i)) embed.add_field(name=f'**{m}人目**',value=f'`{player}`') await ctx.send(embed=embed)
async def _add(self, ctx): conn=r.connect() rp=conn.smembers("人狼参加者") rp2=[j for j in rp] if "0" not in rp2: return await ctx.send("既にゲームが始まっています") pc=0 for rpp in rp: rpp=int(rpp) if rpp == ctx.author.id: pc=1 if pc==0: p=conn.sadd("人狼参加者",ctx.author.id) if p==True: await ctx.send("参加登録しました!") else: await ctx.send("登録に失敗しました") else: await ctx.send("既に登録されています")
async def _remove(self, ctx): conn=r.connect() rp=conn.smembers("人狼参加者") rp2=[j for j in rp] if "0" not in rp2: return await ctx.send("既にゲームが始まっています") pc=0 for rpp in rp: rpp=int(rpp) if rpp == ctx.author.id: pc=1 if pc==1: p=conn.srem("人狼参加者",ctx.author.id) if p==True: await ctx.send("参加削除しました!") else: await ctx.send("削除に失敗しました") else: await ctx.send("参加していません")