Discord Bot Take User's Text and Post it - discord

I am looking for a discord bot made in .py that does those 3 things:
post to a specific channel
whatever user writes then bot deletes it and post it
information of who wrote what in another specific channel. example:
{user} wrote Hi my name is Nick
Thanks in advance! I have not tried something yet, because I am not that experienced. Thanks a lot.

Try this
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='prefix')
#bot.command()
async def say(ctx, channel: discord.TextChannel, *, arg):
message = ctx.message # Get your message
await channel.send(f"{ctx.author}: {arg}") # Send your message
await message.delete() # Delete user message
bot.run('token')

Related

Discord.py wait_for command when user adds reaction

So I need some help!
So far I have the code do the following... Someone inputs the !stage command and then their stage(int)... It sends a message in another where the FTO will react to the message. When reacted the FTO will get a DM with info!
So my question is how do I use wait_for for the user who originally sent the command to be contacted by the bot when the FTO clicks the reactions. Like I need the bot to send that original command user a DM with who clicked the reaction.
#client.command()
async def stage(ctx, *, stage):
ftochannel = client.get_channel(1043289756794093639)
logchannel = client.get_channel(1037550844935147622)
embed=discord.Embed(title=f"{ctx.author.mention} has requested ride along for stage **{stage}**",description=f"If you want to assist this member with their requested stage react below!", color=0x660066)
log=discord.Embed(title=f"Discord Log // User Requested Ride Along in BCSO Discord",description=f'Ran By: {ctx.author.mention}\nActual Command Finish: {ctx.author.mention} has just requested the following stage: {stage}! ',color=0x660066)
emoji = "\N{Large Yellow Circle}"
msg = await ftochannel.send(embed=embed)
await msg.add_reaction(emoji)
await ctx.send("When an FTO member answers me You will get a message from me with more information! Please be patient!")
await logchannel.send(embed=log)
#client.event
async def on_raw_reaction_add(payload):
if str(payload.emoji) == "\N{Large Yellow Circle}":
member = payload.member
sendEmbedToUser = discord.Embed(title=f'Hello', description=f'You have accepted THIS PERSONS Stage RIDE ALONG!\nPlease Arrive in <#1038926472259313732> within **10 Minutes**!\n\nHere is some helpful documentation for your ride along:\n[LINK SHORTNER 1]\n[LINK SHORTNER 1]\n[LINK SHORTNER 1]\n[LINK SHORTNER 1]')
await member.send(embed=sendEmbedToUser)
[]
With some help from friends I no know I need to used wait_for somewhere in the stage command but I have no clue how to do it!

Can I catch discord Dyno bot message and auto reply to it?

As title, my scenario is:
Periodically checking if new messages were sent by Dyno bot to specific channel, and reply to it automatically.
Is it possible?
[update1]
Here are some cases:
select the right option based one the message sent by bot
click the right button based one the message sent by bot
[update2]
add some figures. something like these:
Any suggestion is appreciated.
Using discord.py, you can check if a message is written by a bot and reply to it with:
#client.event
async def on_message(self, message): #call the on_message() function
if (message.author.bot): #check if the author is a bot
await message.reply('Hello, bot!') #reply to the bot

Sending welcome message in discord.py [#bot.event doesn't react?] [duplicate]

This question already has an answer here:
Discord.py on_member_join not responding
(1 answer)
Closed 1 year ago.
I'm having some trouble making sure my bot sends a message when a user joins the server, my code seems to be alright, yet it doesn't send nor print anything
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix=config.PREFIX, case_insensitive=True)
#bot.event
async def on_member_join(member):
print("a member joined")
await bot.get_channel(851883872186400812).send(f"<#!{member.id}> just joined the server! Welcome and enjoy your stay!")
bot.run(config.TOKEN)
You might need to open the "Members" intent. Go to http://discord.com/developers, select your bot and then open this in the "Bot" section:
After doing that. You need to open intents in your code too. Its really simple.
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=config.PREFIX, case_insensitive=True, intents=intents)

Is there a way to make a discord bot that sends a user a message the mentioned number of times?

I've been trying to make a discord bot with discord.py. I know how to make the bot send a message to the specified user, but I was wondering, is there a way to send the message a given number of times? If so, how can I do it?
As an example, if the user types !dm #discorduser hello 5, the bot will send "hello" to the specified user 5 times.
So far, my code is:
import discord
from discord.ext import commands
client = commands.Bot(command_prefix='.')
#client.event
async def on_ready():
print('Bot is ready.')
#client.command()
async def spam(ctx, member: discord.Member, *, content):
channel = await member.create_dm()
await channel.send(content)
client.run('bot token')
Here's my answer for the question, from my understanding you're trying to Direct Message a user x amount of times, and x can be changed depending on what the user wants.
#client.command()
# the arguments are: member, the amount of times you want to DM, and what you want to DM them.
async def spam(ctx, member : discord.Member, amount=1, content=None):
# this loop will keep doing the script below the amount of 'amount' times.
for i in range(amount):
channel = await member.create_dm()
await channel.send(content)

How to check if my discord bot already dmed a person and it wont dm the person again (discord.py)

I have a discord bot that handles with alts, i'm looking for a way that my bot knows if he dmed the person already before (explaining why he was kicked) and it wont dm them again. My function is like this:
#client.event
async def on_member_join(member):
channel = member.guild.text_channels[0]
if something
await channel.send(f"**{member.display_name}** was kicked")
await member.send("**Hi, your account was kicked due to reason** \n"
"**please try again later!**\n"
f"**{member.guild.name}.**")
await member.kick(reason=None)
else:
pass
My problem is that every time someone is kicked my bot dms them and I want it to dm the user kicked only once in their lifetime (without saving which user was dmed before).
would like to get help :)
You could have a look at this but you should at least save their id's to a text file.

Resources