async def on_join(bot, guild, member): datastore = serverdatastore.jsonDatastore welcome_message = datastore["servers"][f"{guild.id}"][ "welcome_message"].replace("{member}", member.mention) if welcome_message == "": return channel_name = datastore["servers"][f"{guild.id}"]["welcome_channel"] if channel_name == "": return channel = get(guild.channels, name=channel_name, type=discord.ChannelType.text) if not channel: return pfp_url = member.avatar_url embed = utils.return_embed("Welcome!", welcome_message, discord.Colour.green()) embed.set_thumbnail(url=pfp_url) await channel.send(embed=embed)
async def on_message(bot, guild, message): if ("administrator", True) in message.author.guild_permissions: return original_text = message.content urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', original_text) if valid_url(urls): return await message.delete() await utils.create_embed("Warning.", f"{message.author.mention}. You are not allowed links.", discord.colour.Color.red(), message.channel) channel_name = serverdatastore.jsonDatastore["servers"][f"{guild.id}"]["audit_log_channel"] channel = get(guild.channels, name=channel_name, type=discord.ChannelType.text) if channel: user = message.author pfp_url = user.avatar_url embed = utils.return_embed(f"{user.name}#{user.discriminator}", f"{user.mention} has been censored for trying to post a link.", discord.Colour.red()) embed.add_field(name="Message", value=original_text) embed.set_thumbnail(url=pfp_url) await channel.send(embed=embed)
async def on_join(bot, guild, member): channel_name = serverdatastore.jsonDatastore["servers"][f"{guild.id}"][ "audit_log_channel"] if channel_name == "": return channel = get(guild.channels, name=channel_name, type=discord.ChannelType.text) if not channel: return pfp_url = member.avatar_url embed = utils.return_embed(f"{member.name}#{member.discriminator}", f"{member.mention} has joined the server!", discord.Colour.green()) embed.set_thumbnail(url=pfp_url) await channel.send(embed=embed)
async def on_message(bot, guild, message): if not swears: init_words() original_text = message.content staff_role = await utils.get_role(guild, "Staff") if staff_role in message.author.roles: return text = parse_message(original_text) profanity_threshold = 0.7 profanity_probability = predict_prob([text])[0] if profanity_probability <= profanity_threshold and not check_swear_list(text): return await asyncio.sleep(1) await message.delete() await utils.create_embed("Warning.", f"{message.author.mention}. Your message was deemed profane.", discord.colour.Color.red(), message.channel) channel_name = serverdatastore.jsonDatastore["servers"][f"{guild.id}"]["audit_log_channel"] channel = get(guild.channels, name=channel_name, type=discord.ChannelType.text) if channel: user = message.author pfp_url = user.avatar_url embed = utils.return_embed(f"{user.name}#{user.discriminator}", f"{user.mention} has been censored.", discord.Colour.red()) embed.add_field(name="Message", value=original_text) embed.set_thumbnail(url=pfp_url) await channel.send(embed=embed)
async def command(bot, guild, message, command, args): if not ("kick_members", True) in message.author.guild_permissions: return muted_role = await utils.get_role(guild, "Muted") prefix = serverdatastore.jsonDatastore["servers"][f"{guild.id}"]["prefix"] if (len(args) == 0): await utils.create_embed("Error.", f"Usage: {prefix}mute <@user> (optional-time-seconds, 5s, 5m, 5h, 5d)", discord.Colour.red(), message.channel) return user_id = args[0].replace("<", "").replace(">", "").replace("@!", "") if not utils.represents_int(user_id): await utils.create_embed("Error.", f"Invalid User.", discord.Colour.red(), message.channel) return user = guild.get_member(int(user_id)) if not user: await utils.create_embed("Error.", f"User not found.", discord.Colour.red(), message.channel) return if muted_role in user.roles: await utils.create_embed("Success!", f"Unmuted {args[0]}!", discord.Colour.green(), message.channel) await user.remove_roles(muted_role) return channel_name = serverdatastore.jsonDatastore["servers"][f"{guild.id}"]["audit_log_channel"] channel = get(guild.channels, name=channel_name, type=discord.ChannelType.text) if (len(args) == 2): time = args[1] if not valid_time(time): await utils.create_embed("Error.", f"Invalid Time", discord.Colour.red(), message.channel) return time_seconds = get_seconds(time) print(time_seconds) await user.add_roles(muted_role) await utils.create_embed("Success!", f"Muted {args[0]} for {time}!", discord.Colour.green(), message.channel) if channel: pfp_url = user.avatar_url embed = utils.return_embed(f"{user.name}#{user.discriminator}", f"{user.mention} has been muted for {time}!", discord.Colour.red()) embed.set_thumbnail(url=pfp_url) await channel.send(embed=embed) await asyncio.sleep(time_seconds) if muted_role in user.roles: await user.remove_roles(muted_role) else: await user.add_roles(muted_role) await utils.create_embed("Success!", f"Muted {args[0]}!", discord.Colour.green(), message.channel) if channel: pfp_url = user.avatar_url embed = utils.return_embed(f"{user.name}#{user.discriminator}", f"{user.mention} has been muted!", discord.Colour.red()) embed.set_thumbnail(url=pfp_url) await channel.send(embed=embed)
async def command(bot, guild, message, command, args): if not ("kick_members", True) in message.author.guild_permissions: return prefix = serverdatastore.jsonDatastore["servers"][f"{guild.id}"]["prefix"] if (len(args) == 0): await utils.create_embed( "Error.", f"Usage: {prefix}kick <@user> (optional-reason)", discord.Colour.red(), message.channel) return user_id = args[0].replace("<", "").replace(">", "").replace("@!", "") if not utils.represents_int(user_id): await utils.create_embed("Error.", f"Invalid User.", discord.Colour.red(), message.channel) return user = guild.get_member(int(user_id)) if not user: await utils.create_embed("Error.", f"User not found.", discord.Colour.red(), message.channel) return if user.top_role > message.author.top_role: await utils.create_embed("Error.", f"You cannot kick that user.", discord.Colour.red(), message.channel) return channel_name = serverdatastore.jsonDatastore["servers"][f"{guild.id}"][ "audit_log_channel"] channel = get(guild.channels, name=channel_name, type=discord.ChannelType.text) if len(args) >= 2: reason = utils.get_combined_message(args, 1) await utils.create_embed("Success!", f"Kicked {args[0]} for: '{reason}'!", discord.Colour.green(), message.channel) await guild.kick(user, reason=reason) if not channel: return pfp_url = user.avatar_url embed = utils.return_embed(f"{user.name}#{user.discriminator}", f"{user.mention} has been kicked!", discord.Colour.red()) embed.add_field(name="Reason", value=reason) embed.set_thumbnail(url=pfp_url) await channel.send(embed=embed) else: await utils.create_embed("Success!", f"Kicked {args[0]}!", discord.Colour.green(), message.channel) await guild.kick(user) if not channel: return pfp_url = user.avatar_url embed = utils.return_embed(f"{user.name}#{user.discriminator}", f"{user.mention} has been kicked!", discord.Colour.red()) embed.set_thumbnail(url=pfp_url) await channel.send(embed=embed)