diff --git a/discordexperiments/discordexperiments.py b/discordexperiments/discordexperiments.py index 533a741..f071c59 100644 --- a/discordexperiments/discordexperiments.py +++ b/discordexperiments/discordexperiments.py @@ -90,24 +90,24 @@ class DiscordExperiments(commands.Cog): @commands.cooldown(1, 10, discord.ext.commands.BucketType.guild) @commands.command() - async def doodlecrew(self, ctx, invite_max_age_in_seconds=86400): + async def sketchheads(self, ctx, invite_max_age_in_seconds=86400): """ - Create a Doodle Crew voice channel invite. + Create a Sketch Heads voice channel invite. Use `0` for `invite_max_age_in_seconds` if you want the invite to be permanent. """ - app_name = "the Doodle Crew game" - await self._create_invite(ctx, 878067389634314250, invite_max_age_in_seconds, app_name) + app_name = "the Sketch Heads game" + await self._create_invite(ctx, 902271654783242291, invite_max_age_in_seconds, app_name) @commands.cooldown(1, 10, discord.ext.commands.BucketType.guild) @commands.command() - async def lettertile(self, ctx, invite_max_age_in_seconds=86400): + async def letterleague(self, ctx, invite_max_age_in_seconds=86400): """ - Create a Letter Tile voice channel invite. + Create a Letter League voice channel invite. Use `0` for `invite_max_age_in_seconds` if you want the invite to be permanent. """ - app_name = "the Letter Tile game" + app_name = "the Letter League game" await self._create_invite(ctx, 879863686565621790, invite_max_age_in_seconds, app_name) @commands.cooldown(1, 10, discord.ext.commands.BucketType.guild) @@ -142,3 +142,33 @@ class DiscordExperiments(commands.Cog): """ app_name = "Checkers in the Park" await self._create_invite(ctx, 832013003968348200, invite_max_age_in_seconds, app_name) + + @commands.cooldown(1, 10, discord.ext.commands.BucketType.guild) + @commands.command() + async def blazing8s(self, ctx, invite_max_age_in_seconds=86400): + """ + Create a Blazing 8s voice channel invite. + Use `0` for `invite_max_age_in_seconds` if you want the invite to be permanent. + """ + app_name = "Blazing 8s" + await self._create_invite(ctx, 832025144389533716, invite_max_age_in_seconds, app_name) + + @commands.cooldown(1, 10, discord.ext.commands.BucketType.guild) + @commands.command() + async def puttparty(self, ctx, invite_max_age_in_seconds=86400): + """ + Create a Putt Party voice channel invite. + Use `0` for `invite_max_age_in_seconds` if you want the invite to be permanent. + """ + app_name = "Putt Party" + await self._create_invite(ctx, 945737671223947305, invite_max_age_in_seconds, app_name) + + @commands.cooldown(1, 10, discord.ext.commands.BucketType.guild) + @commands.command() + async def landio(self, ctx, invite_max_age_in_seconds=86400): + """ + Create a Land-io voice channel invite. + Use `0` for `invite_max_age_in_seconds` if you want the invite to be permanent. + """ + app_name = "Land-io" + await self._create_invite(ctx, 903769130790969345, invite_max_age_in_seconds, app_name) diff --git a/hunting/hunting.py b/hunting/hunting.py index e71c542..e970e58 100644 --- a/hunting/hunting.py +++ b/hunting/hunting.py @@ -7,13 +7,14 @@ import time from typing import Literal import discord -from redbot.core import Config, checks, commands +from redbot.core import Config, checks, commands, bank +from redbot.core.errors import BalanceTooHigh from redbot.core.utils.chat_formatting import (bold, box, humanize_list, humanize_number, pagify) from redbot.core.utils.menus import DEFAULT_CONTROLS, menu from redbot.core.utils.predicates import MessagePredicate -__version__ = "3.1.6" +__version__ = "3.1.7" class Hunting(commands.Cog): @@ -46,10 +47,15 @@ class Hunting(commands.Cog): "channels": [], "bang_time": False, "bang_words": True, + "reward_range": [], + } + default_global = { + "reward_range": [], # For bots with global banks } default_user = {"score": {}, "total": 0} self.config.register_user(**default_user) self.config.register_guild(**default_guild) + self.config.register_guild(**default_global) @commands.guild_only() @commands.group() @@ -76,6 +82,17 @@ class Hunting(commands.Cog): msg += f"[Hunting mode]: {hunting_mode}\n" msg += f"[Bang response time message]: {reaction_time}\n" + if await bank.is_global(): + reward = await self.config.reward_range() + if reward: + reward = f"{reward[0]} - {reward[1]}" + msg += f"[Hunting reward range]: {reward if reward else 'None'}\n" + else: + reward = guild_data['reward_range'] + if reward: + reward = f"{reward[0]} - {reward[1]}" + msg += f"[Hunting reward range]: {reward if reward else 'None'}\n" + for page in pagify(msg, delims=["\n"]): await ctx.send(box(page, lang="ini")) @@ -156,6 +173,36 @@ class Hunting(commands.Cog): toggle_text = "Use the reaction" if toggle else "Type 'bang'" await ctx.send(f"{toggle_text} to react to the bang message when it appears.\n") + @checks.mod_or_permissions(manage_guild=True) + @hunting.command() + async def reward(self, ctx, min_reward: int = None, max_reward: int = None): + """ + Set a credit reward range for successfully shooting a bird + + Leave the options blank to disable bang rewards + """ + bank_is_global = await bank.is_global() + if ctx.author.id not in self.bot.owner_ids and bank_is_global: + return await ctx.send("Bank is global, only bot owner can set a reward range.") + if not min_reward or not max_reward: + if min_reward != 0 and not max_reward: # Maybe they want users to sometimes not get rewarded + if bank_is_global: + await self.config.reward_range.set([]) + else: + await self.config.guild(ctx.guild).reward_range.set([]) + msg = "Reward range reset to default(None)." + return await ctx.send(msg) + if min_reward > max_reward: + return await ctx.send("Your minimum reward is greater than your max reward...") + reward_range = [min_reward, max_reward] + currency_name = await bank.get_currency_name(ctx.guild) + if bank_is_global: + await self.config.reward_range.set(reward_range) + else: + await self.config.guild(ctx.guild).reward_range.set(reward_range) + msg = f"Users can now get {min_reward} to {max_reward} {currency_name} for shooting a bird." + await ctx.send(msg) + @checks.mod_or_permissions(manage_guild=True) @hunting.command() async def next(self, ctx): @@ -376,13 +423,34 @@ class Hunting(commands.Cog): if random.randrange(0, 17) > 1: await self._add_score(guild, author, animal) - msg = f"{author.display_name} shot a {animal}{bangtime}!" + reward = await self.maybe_send_reward(guild, author) + if reward: + cur_name = await bank.get_currency_name(guild) + msg = f"{author.display_name} shot a {animal}{bangtime} and earned {reward} {cur_name}!" + else: + msg = f"{author.display_name} shot a {animal}{bangtime}!" else: msg = f"{author.display_name} missed the shot and the {animal} got away!" self.in_game.remove(channel.id) await channel.send(bold(msg)) + async def maybe_send_reward(self, guild, author) -> int: + max_bal = await bank.get_max_balance(guild) + user_bal = await bank.get_balance(author) + if await bank.is_global(): + range_to_give = await self.config.reward_range() + else: + range_to_give = await self.config.guild(guild).reward_range() + to_give = random.choice(range(range_to_give[0], range_to_give[1] + 1)) + if to_give + user_bal > max_bal: + to_give = max_bal - user_bal + try: + await bank.deposit_credits(author, to_give) + except BalanceTooHigh as e: # This shouldn't throw since we already compare to max bal + await bank.set_balance(author, e.max_balance) + return to_give + @commands.Cog.listener() async def on_message(self, message): if not message.guild: diff --git a/rss/rss.py b/rss/rss.py index 928c239..90a42ec 100644 --- a/rss/rss.py +++ b/rss/rss.py @@ -1048,7 +1048,8 @@ class RSS(commands.Cog): msg += "\n\n\t[X] = html | [\\] = dictionary | [-] = list | [ ] = plain text" msg += "\n\t[*] = specially-generated tag, may not be present in every post" - await ctx.send(box(msg, lang="ini")) + for msg_part in pagify(msg, delims=["\n\t", "\n\n"]): + await ctx.send(box(msg_part, lang="ini")) @checks.is_owner() @rss.group(name="parse")