コード例 #1
0
 async def handle_suggestion(self, message):
     if message.channel.id == SUGGESTIONS_CHANNEL and str.lower(message.content).startswith("suggestion: "):
         write_file("data/suggestions.Json", { "suggestion": message.content[len("suggestion: "):], "jump_url": message.jump_url })
         await message.channel.send("Suggestion saved.")
         channel = self.bot.get_channel(IDK_THIS_CHANNEL)
         text = message.content.replace("Suggestion: ", "", 1)
         await channel.send("**Suggestion: **" + text.replace("suggestion: ", "", 1) + "\n")
コード例 #2
0
 async def warn(self, ctx, user: discord.Member, *, arg):
     if ctx.author.id in moderator_list or ctx.author.id in admin_list:
         if arg:
             user_id = str(user.id)
             moderator_id = str(ctx.author.id)
             warn_dict = {
                 "user_id": user_id,
                 "reason": arg,
                 "epoch": int(time.time()),
                 "moderator_id": moderator_id,
                 "punishment_type": "warn"
             }
             await user.send("You have been warned for the following reason: {0}".format(arg))
             write_file("data/warns.Json", warn_dict)
             await ctx.send("Successfully warned user")
             embed = discord.Embed(title="WARN {0}#{1}".format(user.display_name, user.discriminator), color=0x0d25cc)
             embed.add_field(name="User".format(user.display_name),
                             value="{0}".format(user.mention))
             embed.add_field(name="Moderator".format(user.display_name),
                             value="{0}".format(ctx.author.mention))
             embed.add_field(name="Reason".format(arg),
                             value="{0}".format(arg))
             embed.add_field(name="Channel".format(user.display_name),
                             value="{0}".format(ctx.channel))
             await ctx.guild.get_channel(log_channel).send(embed=embed)
         else:
             await ctx.send("Missing required argument")
     else:
         await ctx.send("You don't have permission to do that, silly.")
コード例 #3
0
 async def tag(self, ctx,  *, arg):
     if ctx.author.id in admin_list:
         arg = arg.split('|')
         arg[0] = str.lower(arg[0])
         write_file('data/tags.Json', arg[1], arg[0])
         await ctx.send("Successfully added tag")
     else:
         await ctx.send("You do that silly")
コード例 #4
0
 async def handle_language(self, message):
     if len(message.content)>3:
         lang = TextBlob(message.content)
         language = lang.detect_language()
         if language:
             if language not in read_file('data/languages.Json'):
                 write_file('data/languages.Json', 1, language)
             else:
                 x = read_file('data/languages.Json')
                 x[language]+=1
                 with open("data/languages.Json", 'w') as file_output_object:
                     json.dump(x, file_output_object, sort_keys=True, indent=4, separators=(',', ': '),
                               skipkeys=True)
コード例 #5
0
 async def on_message(self, message):
     user_data_json = read_file("data/user_data.Json")
     if str(message.author.id) not in user_data_json:
         write_file('data/user_data.Json', {
             'voice_points': 0,
             'text_points': 1,
             'cooldown': time.time()
         }, str(message.author.id))
     else:
         user_data = user_data_json[str(message.author.id)]
         if time.time() - user_data['cooldown'] > 12:
             user_data['cooldown'] = time.time()
             user_data['text_points'] += 1
             write_file('data/user_data.Json', user_data,
                        str(message.author.id))
コード例 #6
0
 async def on_voice_state_update(self, member, before, after):
     channel = after.channel
     if channel is not None:
         if channel.id == 702169810028724297:  # 702169810028724297
             guild = member.guild
             category = self.bot.get_channel(
                 700665944279875654)  # 700665944279875654
             channel_number = random.randint(1111, 9999)
             while channel_number in self.list_numbers_banned:
                 channel_number = random.randint(1111, 9999)
             self.list_numbers_banned.append(channel_number)
             channel = await guild.create_voice_channel(
                 name="Private group {0}".format(channel_number),
                 user_limit=2,
                 category=category)  # create channel
             role = guild.get_role(700732374471934053)
             overwrite = {
                 guild.default_role:
                 discord.PermissionOverwrite(read_messages=False),
                 member:
                 discord.PermissionOverwrite(read_messages=True),
                 role:
                 discord.PermissionOverwrite(read_messages=True),
                 self.bot.user:
                 discord.PermissionOverwrite(manage_permissions=True,
                                             read_messages=True,
                                             manage_channels=True)
             }
             text_channel = await guild.create_text_channel(
                 name="private-group-{0}".format(channel_number),
                 category=category,
                 position=0,
                 overwrites=overwrite)
             message = "**__Welcome to your private chat room!__\n Only users who are in the designated voice channel can see this room! Please follow the rules as these rooms are moderated!\n\nYou can use the p!changelimit (p!cl) command to change the amount of members that can join your channel!\nHave fun!! ||{0} ping ;)||**".format(
                 member.mention)
             await text_channel.send(message)
             await member.move_to(channel)  # move member
             write_file(
                 self.to_delete, value=text_channel.id, key=str(
                     channel.id))  # adds channel id to the "to_delete" list
         to_delete_list = read_file(self.to_delete)
         if str(channel.id) in to_delete_list.keys():
             text_channel = self.bot.get_channel(to_delete_list[str(
                 channel.id)])
             await text_channel.set_permissions(member, read_messages=True)
     channel = before.channel
     if channel is not None:
         to_delete_list = read_file(self.to_delete)
         if len(channel.members) == 0 and str(
                 channel.id
         ) in to_delete_list.keys(
         ):  # checks if channel has no one and if it's in the "to_delete" list
             await channel.delete()
             text_channel = self.bot.get_channel(to_delete_list[str(
                 channel.id)])
             await text_channel.delete()
         elif str(channel.id) in to_delete_list.keys(
         ) and after.channel is not before.channel:
             text_channel = self.bot.get_channel(to_delete_list[str(
                 channel.id)])
             if not member.guild.get_role(
                     700732374471934053) in member.roles:
                 await text_channel.set_permissions(member,
                                                    read_messages=False)