Skip to content

Commit 065146e

Browse files
committed
Merge branch 'develop'
2 parents 85b95b0 + e38cec8 commit 065146e

25 files changed

Lines changed: 2506 additions & 2171 deletions

changelogs/3.10.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SizeBot 3.10 Changelog
2+
3+
*For the last major version's changelog, see [SizeBot 3½ Changelog](https://github.com/sizedev/SizeBot/blob/master/changelogs/3.5.md).*
4+
5+
*For the last minor version's changelog, see [SizeBot 3.9 Changelog](https://github.com/sizedev/SizeBot/blob/master/changelogs/3.9.md).*
6+
7+
We're now verified! This has come with some good and some bad, but I'll explain it all here!
8+
9+
## Slash Commands
10+
- There is a new slash command, `/sb`. To use it, simply run `/sb`, and the the command you usually would after a prefix (for instance, `&stats` is now `/sb stats`.)
11+
- More slash commands will come in the future! This is a stop-gap solution.
12+
- You can still run commands like normal by **pinging the bot instead**, and right now that's the recommended way to run commands.
13+
- For instance, `@SizeBot stats`.
14+
15+
## Triggers
16+
- **Triggers are disabled** for the time being until we can work on a verified-bot-friendly solution.
17+
18+
## Additions
19+
- Added a new stat, `tier`.
20+
- Added a new oommands, `facts`.
21+
22+
## Fixes
23+
- Fixed slow changes not working
24+
- Fixed push buttons not working
25+
- Fixed scale on step not working
26+
- Fixed `start` not working
27+
- Fixed several errors with some user inputs

changelogs/3.11.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# SizeBot 3.11 Changelog
2+
3+
*For the last major version's changelog, see [SizeBot 3½ Changelog](https://github.com/sizedev/SizeBot/blob/master/changelogs/3.5.md).*
4+
5+
*For the last minor version's changelog, see [SizeBot 3.9 Changelog](https://github.com/sizedev/SizeBot/blob/master/changelogs/3.9.md).*
6+
7+
A bit of a smaller update while we ramp up for 4.0!
8+
9+
## Additions
10+
- Added size limits.
11+
- You can set them with `setminimum` and `setmaximum`.
12+
- You can remove them with `resetminimum` and `resetmaximum`.
13+
- Any height change will cap at these sizes, even changes from others.
14+
- Added a new command, `stacked`.
15+
- Use it like `stacked "<object name>" [user]`.
16+
- With no user provided, defaults to yourself.
17+
- Tells you how many of that object is needed to stack to equal your height.
18+
- Added a new command, `toggleallowmatching`.
19+
- Toggles whether or not to allow others to match your size.
20+
- Enables/disables `copyheight`, `outgrow`, and `outshrink`.
21+
- Is enabled by default.
22+
- Added a new command, `list`.
23+
- Currently only supports `list stats`, which will list all stats in the bot.
24+
- As always, new objects added!
25+
26+
## Changes
27+
- `outgrow` and `outshrink` can now take a user argument.
28+
29+
## Fixes
30+
- The bot will now warn you if you've run an unrecognized command.
31+
- Improved error handling and reporting.

pokemon.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

sizebot/cogs/change.py

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import sizebot.data
1111
from sizebot.lib import changes, userdb, nickmanager
1212
from sizebot.lib.diff import Diff, LimitedRate, Rate
13-
from sizebot.lib.errors import ChangeMethodInvalidException
13+
from sizebot.lib.errors import ChangeMethodInvalidException, UserNotFoundException
1414
from sizebot.lib.objs import DigiObject, objects
1515
from sizebot.lib.types import BotContext, GuildContext, StrToSend
1616
from sizebot.lib.units import SV, Decimal
@@ -169,7 +169,7 @@ async def pushme(self, ctx: GuildContext):
169169
category = "change"
170170
)
171171
@commands.guild_only()
172-
async def outgrow(self, ctx: GuildContext, *, obj: DigiObject | None = None):
172+
async def outgrow(self, ctx: GuildContext, *, obj: DigiObject | Member | None = None):
173173
"""Outgrows the next object in the object database, or an object you specify."""
174174
guildid = ctx.guild.id
175175
userid = ctx.author.id
@@ -181,22 +181,38 @@ async def outgrow(self, ctx: GuildContext, *, obj: DigiObject | None = None):
181181
await ctx.send("You have nothing left to outgrow!")
182182
return
183183
obj = objs_larger[0]
184+
name = obj.name
185+
length = obj.unitlength
186+
elif isinstance(obj, Member):
187+
try:
188+
userdata2 = userdb.load(ctx.guild.id, obj.id)
189+
name = userdata2.nickname
190+
length = userdata2.height
191+
except UserNotFoundException:
192+
await ctx.send("This user is not registered with SizeBot!")
193+
return
194+
if not userdata2.allow_matching:
195+
await ctx.send("This user is does not allow others to match their height!")
196+
return
197+
else:
198+
name = obj.name
199+
length = obj.unitlength
184200

185-
if obj.unitlength < userdata.height:
186-
await ctx.send(f"You're already larger than {obj.article} {obj.name}!")
201+
if length < userdata.height:
202+
await ctx.send(f"You're already larger than {obj.article if hasattr(obj, 'article') else ''} {name}!")
187203
return
188204

189205
random_factor = Decimal(random.randint(11, 20) / 10)
190-
userdata.height = obj.unitlength * random_factor
206+
userdata.height = length * random_factor
191207
userdb.save(userdata)
192208

193-
await ctx.send(f"You outgrew {obj.article} **{obj.name}** *({obj.unitlength:,.3mu})* and are now **{userdata.height:,.3mu}** tall!")
209+
await ctx.send(f"You outgrew {obj.article if hasattr(obj, 'article') else ''} **{name}** *({length:,.3mu})* and are now **{userdata.height:,.3mu}** tall!")
194210

195211
@commands.command(
196212
category = "change"
197213
)
198214
@commands.guild_only()
199-
async def outshrink(self, ctx: GuildContext, *, obj: DigiObject | None = None):
215+
async def outshrink(self, ctx: GuildContext, *, obj: DigiObject | Member | None = None):
200216
"""Outshrinks the next object in the object database or an object you specify."""
201217
guildid = ctx.guild.id
202218
userid = ctx.author.id
@@ -209,16 +225,32 @@ async def outshrink(self, ctx: GuildContext, *, obj: DigiObject | None = None):
209225
await ctx.send("You have nothing left to outshrink!")
210226
return
211227
obj = objs_smaller[0]
228+
name = obj.name
229+
length = obj.unitlength
230+
elif isinstance(obj, Member):
231+
try:
232+
userdata2 = userdb.load(ctx.guild.id, obj.id)
233+
name = userdata2.nickname
234+
length = userdata2.height
235+
except UserNotFoundException:
236+
await ctx.send("This user is not registered with SizeBot!")
237+
return
238+
if not userdata2.allow_matching:
239+
await ctx.send("This user is does not allow others to match their height!")
240+
return
241+
else:
242+
name = obj.name
243+
length = obj.unitlength
212244

213-
if obj.unitlength > userdata.height:
214-
await ctx.send(f"You're already smaller than {obj.article} {obj.name}!")
245+
if length > userdata.height:
246+
await ctx.send(f"You're already smaller than {obj.article if hasattr(obj, 'article') else ''} {name}!")
215247
return
216248

217249
random_factor = Decimal(random.randint(11, 20) / 10)
218-
userdata.height = obj.unitlength / random_factor
250+
userdata.height = length / random_factor
219251
userdb.save(userdata)
220252

221-
await ctx.send(f"You outshrunk {obj.article} **{obj.name}** *({obj.unitlength:,.3mu})* and are now **{userdata.height:,.3mu}** tall!")
253+
await ctx.send(f"You outshrunk {obj.article if hasattr(obj, 'article') else ''} **{name}** *({length:,.3mu})* and are now **{userdata.height:,.3mu}** tall!")
222254

223255
# TODO: CamelCase
224256
@tasks.loop(seconds=6)

sizebot/cogs/edge.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ async def clearlargest(self, ctx: GuildContext):
137137
async def edgedebug(self, ctx: GuildContext):
138138
userdata = userdb.load(ctx.guild.id, ctx.author.id)
139139
usersizes = getUserSizes(ctx.guild)
140-
guilddata = guilddb.load(ctx.guild.id)
140+
guilddata = guilddb.load_or_create(ctx.guild.id)
141141
sm = guilddata.small_edge
142142
lg = guilddata.large_edge
143143

@@ -159,7 +159,7 @@ async def on_message(self, m: discord.Message):
159159
return
160160

161161
try:
162-
guilddata = guilddb.load(m.guild.id)
162+
guilddata = guilddb.load_or_create(m.guild.id)
163163
except GuildNotFoundException:
164164
return # Guild does not have edges set
165165

sizebot/cogs/help.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ async def send_command_help(self, ctx: BotContext, cmd: commands.Command):
212212
embed = Embed(
213213
title=signature,
214214
description=description
215-
).set_author(name=f"Help [SizeBot {__version__}]").set_footer(text=f"See `{conf.prefix}help <command>` for more details about a command and how to use it.")
215+
).set_author(name=f"Help [SizeBot {__version__}]").set_footer(text=f"See `help <command>` for more details about a command and how to use it.")
216216

217217
if cmd.aliases:
218218
embed.add_field(name="**Aliases:**", value=", ".join(cmd.aliases), inline=False)
@@ -379,10 +379,10 @@ async def pong(self, ctx: BotContext, subcommand: str = ""):
379379
waitMsg = await ctx.send(emojis.loading)
380380

381381
if subcommand.lower() in ["heartbeat", "discord"]:
382-
response = f"Ping! :ping_pong:\nDiscord HEARTBEAT latency: -{round(self.bot.latency, 3)} seconds"
382+
response = f"Pong! :ping_pong:\nDiscord HEARTBEAT latency: -{round(self.bot.latency, 3)} seconds"
383383
else:
384384
messageLatency = waitMsg.created_at - ctx.message.created_at
385-
response = f"Ping! :ping_pong:\nCommand latency: -{utils.pretty_time_delta(messageLatency.total_seconds(), True)}"
385+
response = f"Pong! :ping_pong:\nCommand latency: -{utils.pretty_time_delta(messageLatency.total_seconds(), True)}"
386386
await waitMsg.edit(content = response)
387387

388388
@commands.command(
@@ -414,6 +414,15 @@ async def invite(self, ctx: BotContext):
414414
f"- (Use this [link](https://discord.com/oauth2/authorize?client_id={ctx.bot.application_id}&permissions=0&scope=applications.commands+bot) if you would like to manually manage the bot permissions).\n"
415415
"If you need help, reach out to DigiDuncan (@digiduncan) and use `&help`! You can also go to this server for additional help: https://discord.gg/bbGjN8dTgk")
416416

417+
@commands.command(
418+
usage = "<list>",
419+
category = "help"
420+
)
421+
async def list(self, ctx: BotContext, list_type: str):
422+
"""List something about SizeBot! """
423+
if list_type in ["stat", "stats"]:
424+
await ctx.send(f"**STATS:**\n{stats_string}")
425+
417426

418427
class HelpCategory:
419428
def __init__(self, cid: str, name: str, description: str, emoji: str):

sizebot/cogs/limits.py

Lines changed: 80 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,28 @@ def __init__(self, bot: commands.Bot):
1919
self.bot = bot
2020

2121
@commands.command(
22+
aliases = ["caps", "limit", "cap"],
2223
category = "misc"
2324
)
2425
@commands.guild_only()
2526
async def limits(self, ctx: GuildContext):
2627
"""See the guild's current caps."""
2728
guilddata = guilddb.load_or_create(ctx.guild.id)
28-
print_low = '*Unset*' if guilddata.low_limit is None else format(guilddata.low_limit, ",.3mu")
29-
print_high = '*Unset*' if guilddata.high_limit is None else format(guilddata.high_limit, ",.3mu")
30-
await ctx.send(f"**SERVER-SET LOW CAPS AND HIGH CAPS:**\nLow Limit: {print_low}\nHigh Limit: {print_high}")
29+
userdata = userdb.load(ctx.guild.id, ctx.author.id)
30+
print_glow = '*Unset*' if guilddata.low_limit is None else format(guilddata.low_limit, ",.3mu")
31+
print_ghigh = '*Unset*' if guilddata.high_limit is None else format(guilddata.high_limit, ",.3mu")
32+
print_ulow = '*Unset*' if userdata.minimum_limit is None else format(userdata.minimum_limit, ",.3mu")
33+
print_uhigh = '*Unset*' if userdata.maximum_limit is None else format(userdata.maximum_limit, ",.3mu")
34+
await ctx.send(f"**SERVER-SET LOW CAPS AND HIGH CAPS:**\nLow Limit: {print_glow}\nHigh Limit: {print_ghigh}\n**USER-SET LOW CAPS AND HIGH CAPS:**\nLow Limit: {print_ulow}\nHigh Limit: {print_uhigh}")
3135

3236
@commands.command(
33-
aliases = ["lowlimit", "lowcap", "setlowcap", "setfloor"],
3437
usage = "[size]",
3538
hidden = True,
3639
category = "mod"
3740
)
3841
@is_mod()
3942
@commands.guild_only()
40-
async def setlowlimit(self, ctx: GuildContext, *, size: SV):
43+
async def setguildminimum(self, ctx: GuildContext, *, size: SV):
4144
"""Set the low size limit (floor)."""
4245
guilddata = guilddb.load_or_create(ctx.guild.id)
4346
guilddata.low_limit = size
@@ -46,14 +49,13 @@ async def setlowlimit(self, ctx: GuildContext, *, size: SV):
4649
logger.info(f"{size:,.3mu} is now the low size cap in guild {ctx.guild.id}.")
4750

4851
@commands.command(
49-
aliases = ["highlimit", "highcap", "sethighcap", "setceiling"],
5052
usage = "[size]",
5153
hidden = True,
5254
category = "mod"
5355
)
5456
@is_mod()
5557
@commands.guild_only()
56-
async def sethighlimit(self, ctx: GuildContext, *, size: SV):
58+
async def setguildmaximum(self, ctx: GuildContext, *, size: SV):
5759
"""Set the high size limit (ceiling)."""
5860
guilddata = guilddb.load_or_create(ctx.guild.id)
5961
guilddata.high_limit = size
@@ -62,14 +64,14 @@ async def sethighlimit(self, ctx: GuildContext, *, size: SV):
6264
logger.info(f"{size:,.3mu} is now the high size cap in guild {ctx.guild.id}.")
6365

6466
@commands.command(
65-
aliases = ["resetlowlimit", "resetlowcap", "clearlowcap", "resetfloor", "clearfloor"],
67+
aliases = ["resetguildminimum"],
6668
usage = "[size]",
6769
hidden = True,
6870
category = "mod"
6971
)
7072
@is_mod()
7173
@commands.guild_only()
72-
async def clearlowlimit(self, ctx: GuildContext):
74+
async def clearguildminimum(self, ctx: GuildContext):
7375
"""Set the low size limit (floor)."""
7476
guilddata = guilddb.load_or_create(ctx.guild.id)
7577
guilddata.low_limit = None
@@ -78,21 +80,75 @@ async def clearlowlimit(self, ctx: GuildContext):
7880
logger.info(f"Cleared low size cap in guild {ctx.guild.id}.")
7981

8082
@commands.command(
81-
aliases = ["resethighlimit", "resethighcap", "clearhighcap", "resetceiling", "clearceiling"],
83+
aliases = ["resetguildmaximum"],
8284
usage = "[size]",
8385
hidden = True,
8486
category = "mod"
8587
)
8688
@is_mod()
8789
@commands.guild_only()
88-
async def clearhighlimit(self, ctx: GuildContext):
90+
async def clearguildmaximum(self, ctx: GuildContext):
8991
"""Set the high size limit (ceiling)."""
9092
guilddata = guilddb.load_or_create(ctx.guild.id)
9193
guilddata.high_limit = None
9294
guilddb.save(guilddata)
9395
await ctx.send("There is now no highest allowed size in this guild.")
9496
logger.info(f"Cleared high size cap in guild {ctx.guild.id}.")
9597

98+
@commands.command(
99+
usage = "[size]",
100+
category = "misc"
101+
)
102+
@commands.guild_only()
103+
async def setminimum(self, ctx: GuildContext, *, size: SV):
104+
"""Set the low size limit (floor)."""
105+
userdata = userdb.load(ctx.guild.id, ctx.author.id)
106+
userdata.minimum_limit = size
107+
userdb.save(userdata)
108+
await ctx.send(f"{size:,.3mu} is now your minimum size.")
109+
logger.info(f"{size:,.3mu} is now the low size cap for user {userdata.id}.")
110+
111+
@commands.command(
112+
usage = "[size]",
113+
category = "misc"
114+
)
115+
@commands.guild_only()
116+
async def setmaximum(self, ctx: GuildContext, *, size: SV):
117+
"""Set the high size limit (ceiling)."""
118+
userdata = userdb.load(ctx.guild.id, ctx.author.id)
119+
userdata.maximum_limit = size
120+
userdb.save(userdata)
121+
await ctx.send(f"{size:,.3mu} is now your maximum size.")
122+
logger.info(f"{size:,.3mu} is now the high size cap for user {userdata.id}.")
123+
124+
@commands.command(
125+
aliases = ["resetminimum"],
126+
usage = "[size]",
127+
category = "misc"
128+
)
129+
@commands.guild_only()
130+
async def clearminimum(self, ctx: GuildContext):
131+
"""Clear the low size limit (floor)."""
132+
userdata = userdb.load(ctx.guild.id, ctx.author.id)
133+
userdata.minimum_limit = None
134+
userdb.save(userdata)
135+
await ctx.send("You no longer have a lower limit.")
136+
logger.info(f"None is now the low size cap for user {userdata.id}.")
137+
138+
@commands.command(
139+
aliases = ["resetmaximum"],
140+
usage = "[size]",
141+
category = "misc"
142+
)
143+
@commands.guild_only()
144+
async def clearmaximum(self, ctx: GuildContext):
145+
"""Set the high size limit (ceiling)."""
146+
userdata = userdb.load(ctx.guild.id, ctx.author.id)
147+
userdata.maximum_limit = None
148+
userdb.save(userdata)
149+
await ctx.send("You no longer have an upper limit.")
150+
logger.info(f"None is now the high size cap for user {userdata.id}.")
151+
96152
@commands.Cog.listener()
97153
async def on_message(self, m: discord.Message):
98154
# non-guild messages
@@ -104,7 +160,7 @@ async def on_message(self, m: discord.Message):
104160
except UserNotFoundException:
105161
return
106162
try:
107-
guilddata = guilddb.load(m.guild.id)
163+
guilddata = guilddb.load_or_create(m.guild.id)
108164
except GuildNotFoundException:
109165
return
110166

@@ -120,6 +176,18 @@ async def on_message(self, m: discord.Message):
120176
userdb.save(userdata)
121177
await m.channel.send(f"{userdata.nickname} hit the upper limit of this guild and has been set to {guilddata.high_limit:,.3mu}.")
122178

179+
if userdata.minimum_limit:
180+
if userdata.height < userdata.minimum_limit:
181+
userdata.height = userdata.minimum_limit
182+
userdb.save(userdata)
183+
await m.channel.send(f"{userdata.nickname} hit their lower limit and has been set to {userdata.minimum_limit:,.3mu}.")
184+
185+
if userdata.maximum_limit:
186+
if userdata.height > userdata.maximum_limit:
187+
userdata.height = userdata.maximum_limit
188+
userdb.save(userdata)
189+
await m.channel.send(f"{userdata.nickname} hit their upper limit and has been set to {userdata.maximum_limit:,.3mu}.")
190+
123191
if userdata.display:
124192
await nickmanager.nick_update(m.author)
125193

0 commit comments

Comments
 (0)