python
1
2
3
4
5 @commands.command()
6 async def vote(self,ctx,*,subject=None):
7 print(ctx.guild.id)
8 print(self.Question)
9 if subject is None:
10 await ctx.send('dont missed my cmd')
11 return a
12 if ctx.guild.id in self.Question:
13 if self.Question[ctx.guild.id] is None:
14 self.adm[ctx.guild.id] = ctx.author
15 self.Question[ctx.guild.id] = subject
16 await ctx.send('i recorded')
17 else:
18 await ctx.send('ican remember 1q')
19 else:
20 await ctx.send('error')
21
22 @commands.command()
23 async def asr(self,ctx,a):
24 if a is None:
25 await ctx.send('missed cmd')
26 if ctx.guild.id in self.Question and a is not None:
27 if self.Question[ctx.guild.id] is not None:
28 self.asr_channel[ctx.guild.id] = ctx.channel
29 answer= a
30 answer_list = answer.split('/')
31 num = len(answer_list)
32 emoji=list()
33 if num >= 1:
34 emoji.append('1️⃣')
35 if num >= 2:
36 emoji.append('2️⃣')
37 if num >= 3:
38 emoji.append('3️⃣')
39 if num >= 4:
40 emoji.append('4️⃣')
41 q_embed = discord.Embed(title='ほーれアンケートだぞ',description=(str(self.Question[ctx.guild.id])),colour=discord.Colour.green())
42 for (l_answer_num,l_answer) in zip(answer_list,emoji):
43 q_embed.add_field(name=(l_answer_num),value=(l_answer),inline=False)
44 self.reaction_message[ctx.guild.id] = await ctx.send(embed=q_embed)
45 for reaction_emoji in emoji:
46 await self.reaction_message[ctx.guild.id].add_reaction(reaction_emoji)
47 self.do_q[ctx.guild.id] = True
48
49
50 @commands.command()
51 async def fin(self,ctx):
52 print(self.asr_channel)
53 if self.do_q[ctx.guild.id] == True:
54 f_re_msg = await self.asr_channel[ctx.guild.id].fetch_message(self.reaction_message[ctx.guild.id].id)
55 result_e = discord.Embed(title='counted!',description=(f_re_msg.jump_url),colour=discord.Colour.magenta())
56 for reaction in f_re_msg.reactions:
57 result_e.add_field(name=str(reaction.emoji),value='emojiwas'+str((reaction.count)-1)+'')
58 await ctx.send(embed=result_e)
59 self.do_q[ctx.guild.id] = False
60 self.Question[ctx.guild.id] = None
61 elif self.do_q[ctx.guild.id] == False:
62 await ctx.send('Noq')
63 self.Question[ctx.guild.id] = None
64 else:
65 self.do_q[ctx.guild.id] = False
66 self.Question[ctx.guild.id] = None
67
これはCogです。僕の友達が書いた投票機能ですが、LISENCEで保護してるのでコピペはやめてください。(僕は許可を取りました)念のためコピペするだけでは動かなくしてます。参考までに