I'm not sure how to dm the interactor in my code. It's in a cog and in a view class for a button
My code-
# Buttons for the embed
class MyView(View):
def __init__(self):
super().__init__(timeout=None)
@button(label="Apply Here!", style=discord.ButtonStyle.green)
async def apply(self, interaction: discord.Interaction, button: Button):
await interaction.response.defer()
user=interaction.user.id
await interaction.followup.send(content="Please await a dm from the bot!", ephemeral=True)
# Here is where I want to send the message
await DMChannel.send(content="Hello")
# Actual command
class ModApp(commands.Cog):
def __init__(self, client):
self.client=client
@commands.Cog.listener()
async def on_ready(self):
print("modapp.py is ready!")
@admin()
@commands.hybrid_command(name="modapp", description="modapp embed")
async def modapp(self, ctx):
embedModApp=discord.Embed(title="Moderator Applications")
embedModApp.set_author(name=f"Requested by {ctx.author.name}", icon_url=ctx.author.avatar.url)
view=MyView()
view.message=(
await ctx.send(embed=embedModApp, view=view))
async def setup(client):
await client.add_cog(ModApp(client))
please tell me how to dm a user and how I can ask multiple questions and save the responses.
You can use user.send. In your code, DMChannel is a class object in
discord.py. You are looking to send a discord.Member a message, which you can do by using the method user.send.Take a moment to read some of the documentation on discord.Member, discord.Interaction.