banterbotapi 0.2.7__tar.gz → 0.2.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/PKG-INFO +1 -1
  2. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterapi/__init__.py +1 -1
  3. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterapi/client.py +17 -30
  4. banterbotapi-0.2.9/banterapi/helpcommand.py +39 -0
  5. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterapi/http.py +22 -0
  6. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterbotapi.egg-info/PKG-INFO +1 -1
  7. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterbotapi.egg-info/SOURCES.txt +1 -0
  8. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/pyproject.toml +1 -1
  9. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/LICENSE +0 -0
  10. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/README.md +0 -0
  11. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterapi/commands.py +0 -0
  12. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterapi/embed.py +0 -0
  13. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterapi/errors.py +0 -0
  14. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterapi/gateway.py +0 -0
  15. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterapi/intents.py +0 -0
  16. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterapi/interactions.py +0 -0
  17. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterapi/models.py +0 -0
  18. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterapi/permissions.py +0 -0
  19. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterbotapi.egg-info/dependency_links.txt +0 -0
  20. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterbotapi.egg-info/requires.txt +0 -0
  21. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/banterbotapi.egg-info/top_level.txt +0 -0
  22. {banterbotapi-0.2.7 → banterbotapi-0.2.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: banterbotapi
3
- Version: 0.2.7
3
+ Version: 0.2.9
4
4
  Summary: Python SDK for building bots on Banter (banterchat.org) — discord.py-style.
5
5
  Author-email: Banter <contact@banterchat.org>
6
6
  License-Expression: MIT
@@ -23,7 +23,7 @@ The library mirrors discord.py conventions where possible. See the Bot,
23
23
  Intents, Embed, and Permissions classes for the main entry points.
24
24
  """
25
25
 
26
- __version__ = "0.2.7"
26
+ __version__ = "0.2.9"
27
27
 
28
28
  from .client import Bot
29
29
  from .intents import Intents
@@ -236,36 +236,8 @@ class Bot:
236
236
  return decorator
237
237
 
238
238
  def _register_default_help(self):
239
- from .embed import Embed
240
-
241
- @self.command(name="help")
242
- async def _help(ctx):
243
- visible = [c for c in self._commands.all() if not getattr(c, "_hidden", False)]
244
- visible.sort(key=lambda c: c.name)
245
- e = Embed(
246
- title=f"{self.user.username if self.user else 'Bot'} — Commands",
247
- description=f"Prefix: `{self.command_prefix}` · {len(visible)} command(s)",
248
- color=self.help_color,
249
- )
250
- lines = []
251
- for cmd in visible:
252
- aliases = f" · aliases: {', '.join(self.command_prefix + a for a in cmd.aliases)}" if cmd.aliases else ""
253
- doc = (cmd.help or "").strip().split("\n", 1)[0]
254
- lines.append(f"`{self.command_prefix}{cmd.name}`{aliases} — {doc}" if doc else f"`{self.command_prefix}{cmd.name}`{aliases}")
255
- if lines:
256
- chunk, chunks = "", []
257
- for line in lines:
258
- if len(chunk) + len(line) + 1 > 1000:
259
- chunks.append(chunk)
260
- chunk = line
261
- else:
262
- chunk = f"{chunk}\n{line}" if chunk else line
263
- if chunk:
264
- chunks.append(chunk)
265
- for i, c in enumerate(chunks):
266
- e.add_field("Commands" if i == 0 else "\u200b", c, inline=False)
267
- e.set_footer(f"Type {self.command_prefix}<command>")
268
- await ctx.reply(embed=e)
239
+ from . import helpcommand
240
+ helpcommand.register(self)
269
241
 
270
242
  async def sync_commands(self):
271
243
  """Push the bot's slash-command definitions to the server.
@@ -414,6 +386,21 @@ class Bot:
414
386
  d = await self._http.get_guild(guild_id)
415
387
  return Guild.from_dict(d) if d else None
416
388
 
389
+ async def edit_guild(self, guild_id, *, name=None, description=None, welcome_channel_id=None):
390
+ """Edit guild name, description (bio), or welcome channel.
391
+
392
+ Requires MANAGE_GUILD in the guild. Server enforces this via
393
+ the bot's actual roles — SDK-side perm claims are ignored.
394
+ Bots can't create or delete guilds; only edits are permitted.
395
+ """
396
+ d = await self._http.edit_guild(
397
+ guild_id,
398
+ name=name,
399
+ description=description,
400
+ welcome_channel_id=welcome_channel_id,
401
+ )
402
+ return Guild.from_dict(d) if d else None
403
+
417
404
  async def get_member(self, guild_id, user_id):
418
405
  """Fetch a guild member by user ID. Returns :class:`Member` or ``None``."""
419
406
  d = await self._http.get_member(guild_id, user_id)
@@ -0,0 +1,39 @@
1
+ """Default !help command — registered when ``Bot(help_enabled=True)``.
2
+
3
+ Kept in its own module so the implementation is easy to find, swap out,
4
+ or copy into a user's bot as a starting template. The default is a
5
+ plain-text listing — no embed, no fancy formatting — because the bot
6
+ author should be free to override with whatever they want, and a
7
+ plain enum is the most predictable starting point.
8
+
9
+ Slash help is intentionally NOT registered. Slash commands are typed
10
+ features the bot author opts in to; a synthetic ``/help`` would clutter
11
+ every bot's autocomplete with no clear benefit. If you want one,
12
+ register it explicitly via ``@bot.slash_command``.
13
+ """
14
+
15
+
16
+ def register(bot):
17
+ """Attach the default ``<prefix>help`` prefix command to ``bot``.
18
+
19
+ Called by :class:`~banterapi.Bot.__init__` when
20
+ ``help_enabled=True``. Re-registering ``help`` after this point
21
+ overwrites the default — the registry's ``add`` is last-write-wins.
22
+ """
23
+
24
+ @bot.command(name="help", help="Lists all registered commands.")
25
+ async def _help(ctx):
26
+ cmds = sorted(bot.commands, key=lambda c: c.name)
27
+ if not cmds:
28
+ await ctx.reply("No commands registered.")
29
+ return
30
+ lines = []
31
+ for cmd in cmds:
32
+ doc = (cmd.help or "").strip().split("\n", 1)[0]
33
+ entry = f"`{bot.command_prefix}{cmd.name}`"
34
+ if cmd.aliases:
35
+ entry += " (" + ", ".join(bot.command_prefix + a for a in cmd.aliases) + ")"
36
+ if doc:
37
+ entry += f" — {doc}"
38
+ lines.append(entry)
39
+ await ctx.reply("\n".join(lines))
@@ -361,6 +361,28 @@ class HTTPClient:
361
361
  "GET", "/guilds/{guild_id}", guild_id=guild_id,
362
362
  ))
363
363
 
364
+ async def edit_guild(self, guild_id, *, name=None, description=None, welcome_channel_id=None):
365
+ """PATCH /guilds/{guild_id} — partial update.
366
+
367
+ Requires MANAGE_GUILD in the target guild. Server enforces the
368
+ check against the bot's actual roles — SDK-reported perms are
369
+ ignored. Bots cannot create or delete guilds regardless of
370
+ perms; those routes aren't exposed for bot tokens.
371
+
372
+ Pass ``description=""`` to clear the guild bio.
373
+ """
374
+ body = {}
375
+ if name is not None:
376
+ body["name"] = name
377
+ if description is not None:
378
+ body["description"] = description
379
+ if welcome_channel_id is not None:
380
+ body["welcome_channel_id"] = welcome_channel_id
381
+ return await self.request(
382
+ Route("PATCH", "/guilds/{guild_id}", guild_id=guild_id),
383
+ json_body=body,
384
+ )
385
+
364
386
  async def list_roles(self, guild_id):
365
387
  """GET /guilds/{guild_id}/roles"""
366
388
  return await self.request(Route(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: banterbotapi
3
- Version: 0.2.7
3
+ Version: 0.2.9
4
4
  Summary: Python SDK for building bots on Banter (banterchat.org) — discord.py-style.
5
5
  Author-email: Banter <contact@banterchat.org>
6
6
  License-Expression: MIT
@@ -7,6 +7,7 @@ banterapi/commands.py
7
7
  banterapi/embed.py
8
8
  banterapi/errors.py
9
9
  banterapi/gateway.py
10
+ banterapi/helpcommand.py
10
11
  banterapi/http.py
11
12
  banterapi/intents.py
12
13
  banterapi/interactions.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "banterbotapi"
7
- version = "0.2.7"
7
+ version = "0.2.9"
8
8
  description = "Python SDK for building bots on Banter (banterchat.org) — discord.py-style."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
File without changes
File without changes
File without changes