-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added in ability to get player scores and reward/punish appropriately
- Loading branch information
Joshua Luckie
committed
Mar 30, 2024
1 parent
be048a9
commit d7d2015
Showing
5 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,60 @@ | ||
from discord.ext import commands | ||
from ..cog_helpers.server_containers import ServerContainer | ||
from ..config.globals import _G | ||
from pprint import pprint | ||
|
||
class Rank_Commands(commands.Cog): | ||
|
||
def __init__(self, bot, **extras): | ||
self.bot = bot | ||
for key, value in extras.items(): | ||
setattr(self, key, value) | ||
if not hasattr(self, "servers"): | ||
self.servers = ServerContainer() | ||
|
||
|
||
@commands.command() | ||
async def pprint_servers(self, ctx): | ||
pprint(self.servers) | ||
|
||
@commands.command() | ||
async def add_server(self, ctx): | ||
self.servers.add_server(ctx.guild.id) | ||
|
||
@commands.command() | ||
async def add_player(self, ctx): | ||
for member in ctx.message.mentions: | ||
self.servers.add_player(ctx.guild.id, member.id) | ||
pprint(self.servers) | ||
|
||
@commands.command() | ||
async def flush(self, ctx): | ||
self.servers.remove_server(ctx.guild.id) | ||
pprint(self.servers) | ||
|
||
@commands.command() | ||
async def get_player(self, ctx): | ||
pprint(self.servers.get_player(ctx.guild.id, ctx.author.id)) | ||
|
||
|
||
@commands.command() | ||
async def add_one(self, ctx): | ||
self.servers.get_player(ctx.guild.id, ctx.author.id).score += 1 | ||
pprint(self.servers) | ||
|
||
|
||
@commands.command() | ||
async def remove_global(self, ctx): | ||
_G.AUTOCREATE = False | ||
|
||
@commands.command() | ||
async def reward_player(self, ctx, score): | ||
for member in ctx.message.mentions: | ||
self.servers.get_player(ctx.guild.id, member.id).score += int(score) | ||
pprint(self.servers) | ||
|
||
@commands.command() | ||
async def ranks(self, ctx): | ||
await ctx.channel.send(ranks) | ||
async def punish_player(self, ctx, score): | ||
for member in ctx.message.mentions: | ||
self.servers.get_player(ctx.guild.id, member.id).score -= int(score) | ||
pprint(self.servers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class PlayerNotFound(Exception): pass |