blob: b6607f2f39471f95f0ac163f8e14dd8f90b0b7a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
from discord.ext import commands
class Send(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
@commands.dm_only()
@commands.is_owner()
async def send(self, ctx, user_id: int, *, message: str):
"""Send a message to a user (follow-up on bug reports)"""
user = await self.bot.fetch_user(user_id)
if not user:
return await ctx.send("User not found.")
elif not message:
return await ctx.send("No message for user.")
try:
await user.send(message)
await ctx.send("Message sent to user.")
except Exception as e:
await ctx.send("Error sending message to user.")
async def setup(bot):
await bot.add_cog(Send(bot))
|