Compare commits
38 Commits
master
...
bangame-de
Author | SHA1 | Date |
---|---|---|
![]() |
9d6ff768f1 | 7 years ago |
![]() |
2dfb757fbd | 7 years ago |
![]() |
b9da8246e1 | 7 years ago |
![]() |
9b266c18be | 7 years ago |
![]() |
3389fe2b0f | 7 years ago |
![]() |
7470af525c | 7 years ago |
![]() |
6d8e1a668e | 7 years ago |
![]() |
0ff00e1deb | 7 years ago |
![]() |
a665c5f827 | 7 years ago |
![]() |
f538b6da53 | 7 years ago |
![]() |
c470bec50a | 7 years ago |
![]() |
59c9ea775b | 7 years ago |
![]() |
495a5d0643 | 7 years ago |
![]() |
8cbaab2815 | 7 years ago |
![]() |
8786156963 | 7 years ago |
![]() |
e1569ab7cf | 7 years ago |
![]() |
afbfb0d49e | 7 years ago |
![]() |
3c2c58dcd7 | 7 years ago |
![]() |
b6884634fe | 7 years ago |
![]() |
12afa30df8 | 7 years ago |
![]() |
dfedfb466b | 7 years ago |
![]() |
9ab8fdce9c | 7 years ago |
![]() |
ffb3e52072 | 7 years ago |
![]() |
417eea4859 | 7 years ago |
![]() |
1f756cf429 | 7 years ago |
![]() |
db01c69da3 | 7 years ago |
![]() |
3a70f7db5f | 7 years ago |
![]() |
eb32d4afd1 | 7 years ago |
![]() |
02b9517688 | 7 years ago |
![]() |
58066b328f | 7 years ago |
![]() |
dfccae00b5 | 7 years ago |
![]() |
f3e3463aed | 7 years ago |
![]() |
29fca5ee9b | 7 years ago |
![]() |
a310394954 | 7 years ago |
![]() |
f6bd695995 | 7 years ago |
![]() |
e632827e4e | 7 years ago |
![]() |
ba506695cc | 7 years ago |
![]() |
0080d22160 | 7 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"
|
||||||
|
],
|
||||||
|
"bot_version": [
|
||||||
|
3,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
"description": "Cog to prevent reactions on specific messages from certain users",
|
"description": "Cog to prevent reactions on specific messages from certain users",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"install_msg": "Thank you for installing ReactRestrict.",
|
"install_msg": "Thank you for installing ReactRestrict.",
|
||||||
"requirements" : [],
|
|
||||||
"short": "[Incomplete] Prevent reactions",
|
"short": "[Incomplete] Prevent reactions",
|
||||||
"tags" : ["react", "reaction", "restrict", "tools", "utils", "bobloy"]
|
"tags": [
|
||||||
|
"react",
|
||||||
|
"reaction",
|
||||||
|
"restrict",
|
||||||
|
"tools",
|
||||||
|
"utils",
|
||||||
|
"bobloy"
|
||||||
|
]
|
||||||
}
|
}
|
Loading…
Reference in new issue