Skip to content

Commit

Permalink
Update usages of Message.reply to be Message.respond
Browse files Browse the repository at this point in the history
  • Loading branch information
tandemdude committed Jan 15, 2021
1 parent c3182a0 commit 3fbeba0
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bot = lightbulb.Bot(token="your_token_here", prefix="!")

@bot.command()
async def ping(ctx):
await ctx.reply("Pong!")
await ctx.respond("Pong!")


bot.run()
Expand Down
2 changes: 1 addition & 1 deletion docs/source/custom-help.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Example:

@bot.command()
async def help(ctx):
await ctx.reply(HELP_MESSAGE)
await ctx.respond(HELP_MESSAGE)

However, the main flaw of this method is that the command will not be auto generated so you will have to add details
for all of your commands, groups, and plugins manually.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Your first bot can be written in just a few lines of code:
@bot.command()
async def ping(ctx):
# Send a message to the channel the command was used in
await ctx.reply("Pong!")
await ctx.respond("Pong!")

# Run the bot
# Note that this is blocking meaning no code after this line will run
Expand Down
4 changes: 2 additions & 2 deletions lightbulb/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def dm_only() -> typing.Callable[[T_inv], T_inv]:
@lightbulb.dm_only()
@bot.command()
async def foo(ctx):
await ctx.reply("bar")
await ctx.respond("bar")
"""

def decorate(command: T_inv) -> T_inv:
Expand Down Expand Up @@ -492,7 +492,7 @@ async def check_message_contains_hello(ctx):
@checks.check(check_message_contains_hello)
@bot.command()
async def foo(ctx):
await ctx.reply("Bar")
await ctx.respond("Bar")
See Also:
:meth:`~.commands.Command.add_check`
Expand Down
6 changes: 3 additions & 3 deletions lightbulb/command_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def command(self, **kwargs) -> typing.Callable:
@bot.command()
async def ping(ctx):
await ctx.reply("Pong!")
await ctx.respond("Pong!")
See Also:
:meth:`~.command_handler.Bot.add_command`
Expand All @@ -241,7 +241,7 @@ def group(self, **kwargs) -> typing.Callable:
@bot.group()
async def foo(ctx):
await ctx.reply("Bar")
await ctx.respond("Bar")
See Also:
:meth:`~.commands.Group.command` for how to add subcommands to a group.
Expand Down Expand Up @@ -303,7 +303,7 @@ def add_command(self, func: typing.Union[typing.Callable, commands.Command], **k
bot = lightbulb.Bot(...)
async def ping(ctx):
await ctx.reply("Pong!")
await ctx.respond("Pong!")
bot.add_command(ping)
Expand Down
6 changes: 3 additions & 3 deletions lightbulb/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def command_error(self):
@lightbulb.owner_only()
@bot.command()
async def foo(ctx):
await ctx.reply("bar")
await ctx.respond("bar")
@foo.command_error()
async def on_foo_error(event):
Expand Down Expand Up @@ -637,11 +637,11 @@ def command(self, **kwargs):
@bot.group()
async def foo(ctx):
await ctx.reply("Invoked foo")
await ctx.respond("Invoked foo")
@foo.command()
async def bar(ctx):
await ctx.reply("Invoked foo bar")
await ctx.respond("Invoked foo bar")
"""

def decorate(func):
Expand Down
12 changes: 6 additions & 6 deletions lightbulb/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,17 @@ def channel(self) -> typing.Optional[hikari.TextChannel]:
return self.bot.cache.get_guild_channel(self.channel_id)
return None

@functools.wraps(hikari.Message.reply)
async def reply(self, *args, **kwargs) -> hikari.Message:
@functools.wraps(hikari.Message.respond)
async def respond(self, *args, **kwargs) -> hikari.Message:
"""
Alias for ``ctx.message.reply(...)``.
Alias for ``ctx.message.respond(...)``.
Replies to the message in the current context.
Args:
*args: The positional arguments :meth:`hikari.messages.Message.reply` is invoked with
**kwargs: The keyword arguments :meth:`hikari.messages.Message.reply` is invoked with
*args: The positional arguments :meth:`hikari.messages.Message.respond` is invoked with
**kwargs: The keyword arguments :meth:`hikari.messages.Message.respond` is invoked with
"""
return await self.message.reply(*args, **kwargs)
return await self.message.respond(*args, **kwargs)

async def send_help(self, obj: typing.Union[commands.Command, plugins.Plugin] = None) -> None:
"""
Expand Down
4 changes: 2 additions & 2 deletions lightbulb/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@bot.command()
async def to_int(ctx, number: int):
await ctx.reply(f"{number}, {type(number)}")
await ctx.respond(f"{number}, {type(number)}")
# If ran with the argument "10"
# The output would be: 10, <class 'int'>
Expand Down Expand Up @@ -145,7 +145,7 @@ async def user_converter(arg: WrappedArg) -> hikari.User:
@bot.command()
async def username(ctx, user: lightbulb.user_converter):
await ctx.reply(user.username)
await ctx.respond(user.username)
"""
try:
user_id = _resolve_id_from_arg(arg.data, USER_MENTION_REGEX)
Expand Down
2 changes: 1 addition & 1 deletion lightbulb/cooldowns.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def cooldown(
@lightbulb.cooldown(10, 1, lightbulb.UserBucket)
@bot.command()
async def ping(ctx):
await ctx.reply("Pong!")
await ctx.respond("Pong!")
This would make it so that each user can only use the ``ping`` command once every ten seconds.
"""
Expand Down
10 changes: 5 additions & 5 deletions lightbulb/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ async def send_paginated_help(text: typing.Sequence[str], context: context_.Cont
for line in text:
pag.add_line(line)
for page in pag.build_pages():
await context.reply(page)
await context.respond(page)

async def resolve_help_obj(self, context: context_.Context, obj: typing.List[str]) -> None:
"""
Expand Down Expand Up @@ -222,7 +222,7 @@ async def object_not_found(self, context: context_.Context, name: str) -> None:
Returns:
``None``
"""
await context.reply(f"`{name}` is not a valid command, group or category.")
await context.respond(f"`{name}` is not a valid command, group or category.")

async def send_help_overview(self, context: context_.Context) -> None:
"""
Expand Down Expand Up @@ -274,7 +274,7 @@ async def send_plugin_help(self, context: context_.Context, plugin: plugins.Plug
", ".join(f"`{c.name}`" for c in sorted(plugin.commands.values(), key=lambda c: c.name))
or "No commands in the category",
]
await context.reply("\n> ".join(help_text))
await context.respond("\n> ".join(help_text))

async def send_command_help(self, context: context_.Context, command: commands.Command) -> None:
"""
Expand All @@ -294,7 +294,7 @@ async def send_command_help(self, context: context_.Context, command: commands.C
f"```{context.clean_prefix}{get_command_signature(command)}```",
get_help_text(command).replace("\n", "\n> ") or "No help text provided.",
]
await context.reply("\n> ".join(help_text))
await context.respond("\n> ".join(help_text))

async def send_group_help(self, context: context_.Context, group: commands.Group) -> None:
"""
Expand All @@ -317,4 +317,4 @@ async def send_group_help(self, context: context_.Context, group: commands.Group
if group.subcommands
else "No subcommands in the group",
]
await context.reply("\n> ".join(help_text))
await context.respond("\n> ".join(help_text))
4 changes: 2 additions & 2 deletions lightbulb/utils/nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ async def _edit_msg(self, message: hikari.Message, page: str) -> hikari.Message:
return await message.edit(page)

async def _send_initial_msg(self, page: str) -> hikari.Message:
return await self._context.reply(page)
return await self._context.respond(page)


class EmbedNavigator(Navigator[hikari.Embed]):
Expand All @@ -305,4 +305,4 @@ async def _edit_msg(self, message: hikari.Message, page: hikari.Embed) -> hikari
return await message.edit(embed=page)

async def _send_initial_msg(self, page: hikari.Embed) -> hikari.Message:
return await self._context.reply(embed=page)
return await self._context.respond(embed=page)
2 changes: 1 addition & 1 deletion lightbulb/utils/pag.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ async def guilds(ctx):
for n, guild in enumerate(guilds, start=1):
pag.add_line(f"**{n}.** {guild.name}")
for page in pag.build_pages():
await ctx.reply(page)
await ctx.respond(page)
"""

def __init__(
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
hikari~=2.0.0.dev97
hikari~=2.0.0.dev98
4 changes: 2 additions & 2 deletions tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,5 @@ async def test_context_edited_timestamp_property(bot, message, command):
async def test_context_reply(bot, message, command):
ctx = context.Context(bot, message, "", "", command)
msg = "super cool message"
await ctx.reply(msg)
message.reply.assert_called_with(msg)
await ctx.respond(msg)
message.respond.assert_called_with(msg)

0 comments on commit 3fbeba0

Please sign in to comment.