Compare commits
38 Commits
master
...
bangame-de
Author | SHA1 | Date |
---|---|---|
bobloy | 9d6ff768f1 | 6 years ago |
bobloy | 2dfb757fbd | 6 years ago |
bobloy | b9da8246e1 | 6 years ago |
bobloy | 9b266c18be | 6 years ago |
bobloy | 3389fe2b0f | 6 years ago |
bobloy | 7470af525c | 6 years ago |
bobloy | 6d8e1a668e | 6 years ago |
bobloy | 0ff00e1deb | 6 years ago |
bobloy | a665c5f827 | 6 years ago |
bobloy | f538b6da53 | 6 years ago |
bobloy | c470bec50a | 6 years ago |
bobloy | 59c9ea775b | 6 years ago |
bobloy | 495a5d0643 | 6 years ago |
bobloy | 8cbaab2815 | 6 years ago |
bobloy | 8786156963 | 6 years ago |
bobloy | e1569ab7cf | 6 years ago |
bobloy | afbfb0d49e | 6 years ago |
bobloy | 3c2c58dcd7 | 6 years ago |
bobloy | b6884634fe | 6 years ago |
bobloy | 12afa30df8 | 6 years ago |
bobloy | dfedfb466b | 6 years ago |
bobloy | 9ab8fdce9c | 6 years ago |
bobloy | ffb3e52072 | 6 years ago |
bobloy | 417eea4859 | 6 years ago |
bobloy | 1f756cf429 | 6 years ago |
bobloy | db01c69da3 | 6 years ago |
bobloy | 3a70f7db5f | 6 years ago |
bobloy | eb32d4afd1 | 6 years ago |
bobloy | 02b9517688 | 6 years ago |
bobloy | 58066b328f | 6 years ago |
bobloy | dfccae00b5 | 6 years ago |
bobloy | f3e3463aed | 6 years ago |
bobloy | 29fca5ee9b | 6 years ago |
bobloy | a310394954 | 6 years ago |
bobloy | f6bd695995 | 6 years ago |
bobloy | e632827e4e | 6 years ago |
bobloy | ba506695cc | 6 years ago |
bobloy | 0080d22160 | 6 years ago |
@ -0,0 +1,5 @@
|
|||||||
|
from .bangame import BanGame
|
||||||
|
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
bot.add_cog(BanGame(bot))
|
@ -0,0 +1,117 @@
|
|||||||
|
import asyncio
|
||||||
|
|
||||||
|
import discord
|
||||||
|
from redbot.core import Config, checks, commands
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
Cog: Any = getattr(commands, "Cog", object)
|
||||||
|
|
||||||
|
|
||||||
|
class BanGame(Cog):
|
||||||
|
"""
|
||||||
|
Ban anyone playing the chosen games
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
self.config = Config.get_conf(self, identifier=66971107197109101)
|
||||||
|
default_guild = {"banned_games": [], "do_ban": False}
|
||||||
|
|
||||||
|
self.config.register_guild(**default_guild)
|
||||||
|
|
||||||
|
@commands.guild_only()
|
||||||
|
@commands.group(aliases=["exclusiverole"])
|
||||||
|
async def bangame(self, ctx):
|
||||||
|
"""Base command for managing exclusive roles"""
|
||||||
|
|
||||||
|
if not ctx.invoked_subcommand:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@bangame.command(name="toggleban")
|
||||||
|
@checks.mod_or_permissions(administrator=True)
|
||||||
|
async def bangame_toggleban(self, ctx):
|
||||||
|
"""Toggles kicking and banning"""
|
||||||
|
|
||||||
|
do_ban = not self.config.guild(ctx.guild).do_ban()
|
||||||
|
await self.config.guild(ctx.guild).do_ban.set(do_ban)
|
||||||
|
|
||||||
|
await ctx.send(
|
||||||
|
"Members will now be {} for playing a banned game".format(
|
||||||
|
"Banned" if do_ban else "Kicked"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
@bangame.command(name="add")
|
||||||
|
@checks.mod_or_permissions(administrator=True)
|
||||||
|
async def bangame_add(self, ctx, game):
|
||||||
|
"""Adds a banned game"""
|
||||||
|
if game in (await self.config.guild(ctx.guild).banned_games()):
|
||||||
|
await ctx.send("That game is already banned")
|
||||||
|
return
|
||||||
|
|
||||||
|
async with self.config.guild(ctx.guild).banned_games() as bg:
|
||||||
|
bg.append(game)
|
||||||
|
|
||||||
|
await self.check_guild(ctx.guild)
|
||||||
|
|
||||||
|
await ctx.send("Banned game added: {}".format(game))
|
||||||
|
|
||||||
|
@bangame.command(name="delete")
|
||||||
|
@checks.mod_or_permissions(administrator=True)
|
||||||
|
async def bangame_delete(self, ctx, game):
|
||||||
|
"""Deletes a banned game"""
|
||||||
|
if game not in (await self.config.guild(ctx.guild).banned_games()):
|
||||||
|
await ctx.send("That game is not banned")
|
||||||
|
return
|
||||||
|
|
||||||
|
async with self.config.guild(ctx.guild).banned_games() as bg:
|
||||||
|
bg.remove(game)
|
||||||
|
|
||||||
|
await ctx.send("{} is no longer banned".format(game))
|
||||||
|
|
||||||
|
@bangame.command(name="list")
|
||||||
|
@checks.mod_or_permissions(administrator=True)
|
||||||
|
async def bangame_list(self, ctx):
|
||||||
|
"""List current banned games"""
|
||||||
|
banned_games = await self.config.guild(ctx.guild).banned_games()
|
||||||
|
|
||||||
|
out = "**Banned Games**\n\n"
|
||||||
|
|
||||||
|
for game in banned_games:
|
||||||
|
out += "{}\n".format(game)
|
||||||
|
|
||||||
|
await ctx.send(out)
|
||||||
|
|
||||||
|
async def check_guild(self, guild: discord.Guild):
|
||||||
|
game_set = set(await self.config.guild(guild).banned_games())
|
||||||
|
for member in guild.members:
|
||||||
|
try:
|
||||||
|
await self.ban_or_kick_banned_games(member, game_set=game_set)
|
||||||
|
except discord.Forbidden:
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def ban_or_kick_banned_games(self, member: discord.Member, game_set=None):
|
||||||
|
if game_set is None:
|
||||||
|
game_set = set(await self.config.guild(member.guild).banned_games())
|
||||||
|
|
||||||
|
if member.activity is not None and member.activity.name in game_set:
|
||||||
|
do_ban = await self.config.guild(member.guild).do_ban()
|
||||||
|
|
||||||
|
if do_ban:
|
||||||
|
await member.ban(reason="Plays {}".format(member.activity.name))
|
||||||
|
else:
|
||||||
|
await member.kick(reason="Plays {}".format(member.activity.name))
|
||||||
|
|
||||||
|
async def on_member_update(self, before: discord.Member, after: discord.Member):
|
||||||
|
if before.activity == after.activity:
|
||||||
|
return
|
||||||
|
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
|
game_set = set(await self.config.guild(after.guild).banned_games())
|
||||||
|
|
||||||
|
if after.activity is not None and after.activity.name in game_set:
|
||||||
|
try:
|
||||||
|
await self.ban_or_kick_banned_games(after, game_set=game_set)
|
||||||
|
except discord.Forbidden:
|
||||||
|
pass
|
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"author": [
|
||||||
|
"Bobloy"
|
||||||
|
],
|
||||||
|
"bot_version": [
|
||||||
|
3,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"description": "Kick or ban members that play a banned game",
|
||||||
|
"hidden": false,
|
||||||
|
"install_msg": "Thank you for installing BanGame. Get started with `[p]load bangame` and `[p]help BanGame`",
|
||||||
|
"short": "Ban games",
|
||||||
|
"tags": [
|
||||||
|
"fox",
|
||||||
|
"bobloy",
|
||||||
|
"utility",
|
||||||
|
"tools"
|
||||||
|
]
|
||||||
|
}
|
@ -1,10 +1,22 @@
|
|||||||
{
|
{
|
||||||
"author" : ["Bobloy"],
|
"author": [
|
||||||
"bot_version" : [3,0,0],
|
"Bobloy"
|
||||||
"description" : "Cog to prevent reactions on specific messages from certain users",
|
],
|
||||||
"hidden" : true,
|
"bot_version": [
|
||||||
"install_msg" : "Thank you for installing ReactRestrict.",
|
3,
|
||||||
"requirements" : [],
|
0,
|
||||||
"short" : "[Incomplete] Prevent reactions",
|
0
|
||||||
"tags" : ["react", "reaction", "restrict", "tools", "utils", "bobloy"]
|
],
|
||||||
|
"description": "Cog to prevent reactions on specific messages from certain users",
|
||||||
|
"hidden": true,
|
||||||
|
"install_msg": "Thank you for installing ReactRestrict.",
|
||||||
|
"short": "[Incomplete] Prevent reactions",
|
||||||
|
"tags": [
|
||||||
|
"react",
|
||||||
|
"reaction",
|
||||||
|
"restrict",
|
||||||
|
"tools",
|
||||||
|
"utils",
|
||||||
|
"bobloy"
|
||||||
|
]
|
||||||
}
|
}
|
Loading…
Reference in new issue