#discord-bots
1 messages · Page 128 of 1
XDDOS.jar
Not sure if this question belongs here, but it's the best fitting place on the server.
What Docker container would I use to run my Python Bot? (I'm on Synology Nas)
And how would I run it on that container?
There is a docker container specialized for python applications
I tried that container, couldn't figure out how to run my bot on it.
What problem were you having?
Running the file, also the mount path.
For example, I got into the Py console just fine.
Running the file should just be python <filename>.py
Syntax error
Type exit() first, then run it
That kills the server.
It kills the interactive REPL
oh you're already inside the container?
Usually you wouldn't be inside the container doing stuff
How else would I do it?
Give it instructions on how to build your applications and run
start the container and let it do its thing
that's kind of the whole point of docker :p
Where to I put those instructions though
I know, but synology docker is UI based
in the Dockerfile
Which is located at?
You might want to check out the docker documentation for more information
Top level project directory
you'll have to create it most likely
Im so silly
Shared folder?
What do you mean?
Yeah, but you still shoudn't be inside the container
its mean to just do its own thing
bruh how did u know
replit has similar issues with sqlite, it clears the data often as well
just use a proper vps tbh
bruuuuuUUHHHhhHHHHUHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

sorry I was outside being busy I just came back, I'll check all this thank you a lot for helping me 
"how do I make it so" vibes
ok im back
can nextcord take user input with slash commands in python
yes, how? look in the examples directory of nextcord's github repo
k thanks thts all i needed
need help checking if theres a space in a string in slash
!e ```py
print(" " in "string-with space")
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
True
https://discord.com/developers/active-developer
thank me later
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
anyone have any examples of discord py, using buttons with @bot.listen commands.
how do i send a embed w/ buttons on a @bot.listen
What event?
Why not use slash commands?
i need it to send on message
i have a ticket bot
You can just use the View kwarg
example?
class h(discord.ui.View):
def __init__(self):
super().__init__()
@discord.ui.button(label="h", style=discord.ButtonStyle.gray)
async def h(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message("ok its done")
self.stop()
@bot.command()
async def ask(ctx: commands.Context):
await ctx.send("do u want to sddsfgsdfg", view=h())
await h().wait()
bot.run(token)
thats how i did it but now i have another question
when i click the button twice, on the second time it just says "Interaction failed"
how do i fix this (my code is up there)
but its not @bot command its @ listen
not for me
huh
read
Basically this allows you to listen to multiple events from different places e.g. such as on_ready()
are you getting an error when you press the button a second time?
nope it just doesnt work
Because you got self.stop() when a button is pressed.
how do i make my bot respond to a question without using on_message?
show code
how can i send the message i type back ?
all of it also not photo please
@bot.event
async def on_message(msg):
if msg.author == bot.user:
# if the author is the bot itself we just return to prevent recursive behaviour
return
if msg.content == "$response":
sent_message = await msg.channel.send("Waiting for response...")
res = await bot.wait_for(
"message",
check=lambda x: x.channel.id == msg.channel.id
and msg.author.id == x.author.id
and x.content.lower() == "yes"
or x.content.lower() == "no",
timeout=None,
)
if res.content.lower() == "yes":
await sent_message.edit(content=f"{msg.author} said yes!")
else:
await sent_message.edit(content=f"{msg.author} said no!")```
Like this but with message being send instead of "yes" or "no"
import discord
from discord.ext import commands
intents = discord.Intents.default()
bot = discord.ext.commands.Bot("prefix", intents=intents)
@bot.command(name="name", description="h")
async def name(ctx):
await ctx.reply("h")
fake mm bot
LOL WTF
but thats a command
i just need the bot to reply to id a user sends
pls help
idk but try searching the docs for author
? author
no no you dont understand my question i think
oh
like you do $respone and it sends a message and i answer with yes or no and it edits it to yes or no bla bla bla but i want it to send the message i send instead of yes or no to be send
oh idk how to do that'
ok
class Question:
def __init__(self, view):
self.view = view
async def ask():
await self.ctx.send('Hello world', view=view)
print('View sent with all items')
self.view.clear_items()
self.view.stop()
print('View items cleared and closed')
Hi, since I'm not understanding the proper behavior of View.clear_items() and View.stop(), this case does not work for some reason.
Also there's another case where it doesn't work.
In callback functions this code won't delete the items but will edit the message:
async def callback(self, interaction: Interaction):
assert self.view is not None
if self.view.ctx.author.id == interaction.user.id:
await interaction.response.edit_message(content=self.edit_with)
self.view.canceled = True
self.view.clear_items()
self.view.stop()
but moving self.view.clear_items() above interaction.response.edit_message() will work.
I'm confused 

what yall think about the new "active developer" badge
too hard to obtain :o
like your bot has to be in tons of servers etc
no lol
you just need to have one global application command, and thats it
i mean i got a verified bot, but i chose my bot which is specifically for the support server. its just in that server and everything worked as intended
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
i don't see it lol
oh i see
I'll check that another time tbh, I'm more worried by my code not working properly for now lol
you need to edit your message with the "new" view
"You are not eligible for the Active Developer Badge" 🥲
damn
you can save your message in a variable, and then just call the .edit() function on it
you should have a bot which has one of its app commands used atleast once in last 1 month
doesn't work still
let me try this
thing is that this is inside of a button callback function editing a message that i can't really pass to it
wdym
show me your code
I'm not understanding the proper behavior of View.clear_items() and View.stop()
View.clear_itemsremoves all items from the current view object. !! It doesn't remove them from the message, you have to edit it to accomplish this !!
View.stopis mostly used withView.wait.View.stopis basically a manual/program timeout
but moving self.view.clear_items() above interaction.response.edit_message() will work.
Yeah, cause you're editing the message after you clear all items
Ah, I don't tend to use app commands, that's probably why :I
just create one and use it once, thats all you need
ohhhhhhh tyyyyy
hi sarth 
ello
what's good folks
how to fix?
Don't name your list "random"
the active dev badge apparently
There's already a module called "random"
it was released like idk 2 hrs ago?
Ugh. People getting worked up about badges again?
Guess I gotta wait a bit then
i mean thats free, literally anyone who has a bot with "1" app command can claim it
So not that special then
honestly pretty sad that you can actually get it that easily ngl, should've been just everyone who got a verified bot gets it at least. this way literally anybody can get it lol
its ugly as well, wish i could just remove it
facts
does anyone know i can store lots of numbers in a variable but not write all the numbers
for example 1 to million
class range(stop)``````py
class range(start, stop[, step])```
The arguments to the range constructor must be integers (either built-in [`int`](https://docs.python.org/3/library/functions.html#int "int") or any object that implements the [`__index__()`](https://docs.python.org/3/reference/datamodel.html#object.__index__ "object.__index__") special method). If the *step* argument is omitted, it defaults to `1`. If the *start* argument is omitted, it defaults to `0`. If *step* is zero, [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "ValueError") is raised.
For a positive *step*, the contents of a range `r` are determined by the formula `r[i] = start + step*i` where `i >= 0` and `r[i] < stop`.
For a negative *step*, the contents of the range are still determined by the formula `r[i] = start + step*i`, but the constraints are `i >= 0` and `r[i] > stop`.
You're looking for a random number?
yeah so when i run a command it gens a random number
!d random.randint
random.randint(a, b)```
Return a random integer *N* such that `a <= N <= b`. Alias for `randrange(a, b+1)`.
im using random libabry
Can someone send me a first step code of python bot so that it reacts if i send hi for example
you can use on_message event, and check if message.content is "hi"
!d discord.Message.add_reaction then use this to add the reaction
await add_reaction(emoji, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Adds a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji "discord.Emoji").
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") to do this. If nobody else has reacted to the message using this emoji, [`add_reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") is required.
Changed in version 2.0: `emoji` parameter is now positional-only.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.11)") instead of `InvalidArgument`.
import discord
import os
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
client.run(os.getenv('TOKEN'))```
why does this now work
you need to enable message_content intents
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
Got an Error: TypeError: expected token to be a str, received <class 'NoneType'> instead
you didnt load the env
from discord import Intents
from discord.ext import commands
import os
intents = Intents.default()
intents.members = True
client = commands.Bot(command_prefix="!", intents=intents)
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
client.run(os.getenv(TOKEN)
Changed to this
yeah the code is correct, but i said you need message_content intents, not members
Doesnt work also for me
.
how to load it?
pip install python-dotenv
import dotenv
dotenv.load_dotenv()
from discord import Intents
from discord.ext import commands
import os
import dotenv
dotenv.load_dotenv()
intents = Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix="!", intents=intents)
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
client.run(os.getenv('TOKEN'))```
So like this
0hhh
anyone know how i can add letters when using random.randint
where xD Didnt work with Discord.py up to now xD
https://discord.dev
applications -> your bot -> "Bot" menu -> turn on MESSAGE CONTENT Intents from below
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Got it
no you can't
But also the error xD
did you save after making changes?
any idea how to achieve this:
class Question:
def __init__(self, ctx, view, content, embed=None, embeds=None):
self.ctx = ctx
self.view = view
self.embed = embed
self.embeds = embeds
self.canceled = False
self.content = content
async def question(self) -> Message:
return await self.ctx.send(
self.content, view=self.view, embed=self.embed, embeds=self.embeds
)
async def check_cancel(self):
message = await self.question()
await self.view.wait()
if self.canceled:
await message.edit(content=self.content, view=None)
return True
# Inside another class:
tasks = [
question_task := asyncio.create_task(await_reportee(self)),
cancel_task := asyncio.create_task(self.check_cancel()),
]
done_task, pending_task = await asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED)
I want the question() message to remove items if check_cancel() is triggered by the button callback of the view, or if the answer to the question() is right. I would need to pass the output question() to check_cancel() before it outputs which is nonesense :/
I'm kinda lost in OOP it's still new to me lol
yes oc
how can i show it to my sqlf? I am kinda lost ik+
what
from what i understand, your code is doing this ```
- check_cancel called:
- question called
- waiting for the view to exit
- checking if self.cancel is True
- edit the message if self.cancel is True
Just meaning how can in remove it and show you the env
dont know it - never worked with it
do you have a .env file?
this one is actually working, I don't know how to explain my problem
so where did you get the inspiration to use os.getenv
maybe some example could help?
I probably wouldn't do that create_task stuff tbh, you schedule the task to the event loop concurrently, meaning that your question_task or cancel_task could be executed before the other
is there a easier way?
if yes i prefer
just pasting your token there yes
so i can delete load_dotenv
sure
and the rest with intent?
it will stay
Thought I answered this question yesterday
client = commands.Bot(command_prefix="!", intents=intents)
@commands.command()
async def test(ctx):
await ctx.send('test')
client.add_command(test)
Why does it now work if i write !test test in the chat?
Do you have an on_message event
change .event on on_message to .listen()
client = commands.Bot(command_prefix="!", intents=intents)
@commands.event()
async def test(ctx):
await ctx.send('test')
client.add_command(test)
cant find on_message
.
@client.listen()
async def on_message(message):
...
what do you do for this
wdym do be elaborate
And than message.content.startwith? or what?
sorry not possible u cant just put a ss and say nothing no clue how to start
for what? just use a command
user input
How do I make the title of an embed a link?
give description of what it supposed to do and error pls
OK I solved it !!! I just struggled managing the flow of data inside my classes but I'm fine now.
Last thing is:
# timeout function of a view
async def on_timeout(self):
self.clear_items()
self.stop()
await self.message.edit(content="Report cancelled due to timeout.", view=self)
self.canceld = True
that self.message I need it and I don't find a way to get it there lol
gg 

show what the user wrote and multiply it and show in a embed
pass message as a arg and make it an instance bound var
!d discord.ext.commands.Bot.wait_for
wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.11)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.11)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.11)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
how can i do that? the message is created af... WAIT A MINUTE !
lemme try something 
async def setup_hook(self):
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await self.load_extension(f"cogs.{filename[:-3]}")
await self.tree.sync(guild=discord.Object(id=1038882741510488105))
@bot.tree.context_menu(name="Hello", guild=discord.Object(id=1038882741510488105))
async def hello(interaction: discord.Interaction, message: discord.Message):
await interaction.response.send_message("sup")
don’t say anything about the way i sync because i’m changing it later but the app commands doesn’t work.. my slash commands do just not apps.
message is created so pass the message in the bracket then in class self.message = message
@bot.tree.command
YESSSSKNGMJLZEMGLEZRGERZ%GZE
thank youuuuuu I'm so happy omg !
👍
command?
check the pins
ty so much

💐
unsupported type annotation {annotation!r}
raise TypeError(f'unsupported type annotation {annotation!r}')
TypeError: unsupported type annotation <class 'discord.message.Message'>
@shrewd apex …
🚶
lmaoo
can u tell me the difference other than its name
context menu
I'll just let someone else help u
How can I tell my DIscord bot to address a specific person (name, tagg)? Wouldn't want to tell it by command but by another script so to speak (python)
@shrewd apex you know it, i know it xD
i didn't get u
see if not a command u can use on_message event if not from discord at all
then u would have to make an endpoint/websocket ur bot app is listening to and send data there
wait i will explain it a bit more
if u just want the name and tag then
property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.name "discord.User.name")
and .discriminator
I have a script where you can enter a username to which an automatic message (DM) should be sent. How can I send a DM to people in such a way that I make the trigger for the DM with another script, so to speak. Do you understand me?
@shrewd apex
i didn't get in context of what so if u just wanna send a dm whats wrong with a command and whats a script here u need to be specific is it part of the bot or not
can someone give me a example of you writing a number, the bot multiplies that number and show it in a embed?
hello
hi o/
No problem, just try it by my self and come tomorrow back to you ;D
hello
self.view.clear_items()
self.view.stop()
await self.question.edit(content=self.content, view=self.view)
these don't work, but when I remove the two first lines it does... There must be something i'm missing about those two methods
hello, i am turkish, do you have any turkish people, he will teach me python
thing is that when i edit the message with view=None the view timeout function still edits the message... so I need to stop it
Also ```python
class Reportee(Question):
def init(self, ctx: Context):
super().init(ctx, QuestionView(ctx, None, 30, None), AWAIT_REPORTEE_MESSAGE)
when I use `self.view` inside this class it says that it's an Unknown argument, but I passed it to the super class so i'm kinda confused
Use client.wait_for, store the message in a list by appending -> get the result within that list and use it multiply by your number and make a variable of the multiplied number and use it in the embed 🙃
aaaa
How do you get the bot to save your message in a variable
Or wtv
class MyView(View):
def __init__(self, ...):
# Content of my view
class Question():
def __init__(self, ctx, view):
self.ctx = ctx
self.view = view
async def ask(self):
self.question = await self.ctx.send('Hello...', view=self.view)
class Age(Question):
def __init__(self, ctx):
super().__init__(ctx, MyView(...))
async def await_age(self):
async def check_answer(self):
await self.ask()
# Other things to check
async def check_cancel(self):
# Bunch of stuff that check if the cancel button has been clicked, then execute code below
self.view.clear_items()
self.view.stop()
self.question.edit('... World !', view=self.view)
ask_age = Age(ctx)
ask_age.await_age()
I tried to make a miniature of the structure of my code to explain my problem. So here it seems that self.view inside Age class isn't being accessed for some reason. Why is that?
does it raise some error?
if doesn't
i edited my code i apologise, now it's REALLY representative of the problem
I think the problem comes from
async def papa_method(self):
async def baby_method(self):
self.view
that self being passed to both, I assume it's the class containing these methods right? And it's the same self right?
well, you are never calling those two function anywhere
code= https://paste.nextcord.dev/?id=1668046023263318
i need help with the transcript system.
So basically there both html files (refering to the 2 pictures i sent)
but the one thats like white only collects the message history of the channel
i wanna know how i can make it collect embeds, attachments, channel names, the server name/logo, and have the html file have the same colour as discord.
oh yes yes in my code i do actually
mind showing full code? self is not needed there at all
since its already in the parent function
I'll be glad to ! hang on a second :D
so here's the scenario it isn't working:
when I invoke the command s-report, it will ask me an ID
if I put a wrong ID, it will remove the Cancel button from the first message, and send me Invalid ID with a new cancel button in it.
then if I write cancel everything will cancel. but that first message will transform to Cancelled because of time out when it's supposed to be stopped
in other words: lines 135 and 136 if you remove them, line 138 will work, and if you activate them, it won't ><
Try to just comment out the self.view.stop() line and see if it works
Line 136
Also if you want to clear all the items from a view why not just use view=None
If you reread what developer. wrote, you can use client.wait_for() to store the message they sent in a list, then multiply the number in that list and assign it to a variable, then use that variable in the embed
it does 
I mean... it doesn really work like i want but it works
Self.view.stop() will make it so no interactions with that view work anymore. Best to call that after you're completely done with it
Maybe move it below your edit statement?
What does this message mean
[2022-11-10 17:01:40] [INFO ] discord.gateway: Shard ID None has successfully RESUMED session 00ac666ecad2788ba94afebbc6086957.
I'm getting it a ton
Your client disconnected and reconnected to the gateway
I see
discord.py will seamlessly handle it for you
It clogs the terminal though :/
I suppose
they should make it a nicer color than red
especially since its just info and not an actual error
can i fetch a single role from my guild
or is there a way to see if a user has a role from just the id
nvm i think i got it with the search bar
...maybe
Anyone know why I’m getting this error? I’m can’t seem to find why..
Ignoring exception in on_connect
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 377, in _run_event
await coro(*args, **kwargs)
File "/home/container/.local/lib/python3.9/site-packages/discord/bot.py", line 1138, in on_connect
await self.sync_commands()
File "/home/container/.local/lib/python3.9/site-packages/discord/bot.py", line 692, in sync_commands
registered_commands = await self.register_commands(
File "/home/container/.local/lib/python3.9/site-packages/discord/bot.py", line 570, in register_commands
data = [cmd["command"].to_dict() for cmd in filtered_deleted]
File "/home/container/.local/lib/python3.9/site-packages/discord/bot.py", line 570, in <listcomp>
data = [cmd["command"].to_dict() for cmd in filtered_deleted]
File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 841, in to_dict
"options": [o.to_dict() for o in self.options],
File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 841, in <listcomp>
"options": [o.to_dict() for o in self.options],
File "/home/container/.local/lib/python3.9/site-packages/discord/commands/options.py", line 315, in to_dict
"type": self.input_type.value,
AttributeError: 'NoneType' object has no attribute 'value'
helps if i have correct id in the first place...
self.input_type doesnt exist is what its telling you
which makes no sense to me
show the applicable part of your code
well this happened with my help cmd I think so I’ll show that code
it says the error is in on_connect
but if it happened with the help command something there is probably doing something weird
@bot.slash_command(description = "View Aziel's current commands.")
async def help(self, ctx: discord.ApplicationContext):
if not ctx.author.id == 831118106876969021:
return await ctx.respond("This command is under maintenance.", ephemeral = True)
pages = [
discord.Embed(title = "test page 1"),
discord.Embed(title = "test page 2")
]
await ctx.respond(embeds = pages[0] if isinstance(pages[0], list) else [pages[0]], view = ButtonMenu(pages, 10, ctx.author))
I’m not overriding the on_connect event
so it’s using the default lib one
does it send anything on discord? like the ephemeral message
the command isn’t even being registered
do you have other commands that are working?
yes, all my other commands are working
do you have a command to sync your commands with discord?
alright. just asking because that seems like the rabbit hole this error goes down, something not syncing
so I’m thinking it’s failing to register my command therefore raising the error
yeah
but idk what’s wrong
im not sure, dont use pycord. im sure someone else who knows it better will be in here before too long
alrighty, thanks :) although I’ve gotta head off in around 20 mins since it’s almost 1am for me
to start your bot?
yh
maybe async def on_ready(), but to run the bot usually bot.run(token)
no it's ok i got it
async with self.bot:
self.loop.create_task(self.bot.start(self.config.token)) # type: ignore
await self.bot.wait_until_ready()
thx anw
how can i make this task run just once a day? as it stands it just runs endlessly
my giveaway bot puts the people who entered the giveaway in a list and pulls winners from that list. i want to give people additional entries for boosting the server, so i add them to the list multiple times for that. how do i prevent the bot from choosing the same person twice?
make the task loop every 24 hours
i second this
choosing the same person twice, as in between multiple giveaways?
or does your giveaway pick multiple people
no, i forgot to mention i can set it for multiple winners
i think what you could do is write a custom random.choice or something like that
i forgot i had seconds = 1 in the loop, welp i fell like an idiot now😂
right now its just a random.choice from the list of people with multiple entries. i just dont know how to make sure i get a unique user each time
^ if anyone knows, please ping me!
oh apparently random.sample() doesnt give duplicates
do you have all intents? idk exactly about your error but i had something similar due to wrong intents
yes?
they’re all enabled
where is the problem?
when my bot is started
I recieve the error in my console
^ this error
can I run a bot in a loop provided by me?
yeah i guess so
what do you mean by that exactly 😆
rather than bot starting a async loop on it's own
the event loop
Why do u need to?
sure just pass the loop into the loop= kwarg of your bot/client constructor
Guys why i getting error
Cannot send empty message
This is my code - https://paste.pythondiscord.com/osugezezac
anyone seen this error before?py discord.app_commands.errors.CommandInvokeError: Command 'addpoints' raised an exception: InvalidDocument: cannot encode object: <Member id=914884204926468168 name='amber' discriminator='5807' bot=False nick=None guild=<Guild id=975074982474448947 name='Primetime Flips' shard_id=0 chunked=False member_count=226>>, of type: <class 'discord.member.Member'>
Code worked on my pc but on clients pc it seems to be running into an error?
it seems like it's not detecting user "amber" as a discord member yk
Can you show us your code?
for sure
newData = {
"_id" : uID,
"Discord Name" : username,
"Points" : points
}
you're trying to add the member object itself to the database
it doesn't know how to encode it so it's in a format your database supports
you want to use username.name instead
oh ok ill swap that and see if it works, any idea why it was working on my side?
Not sure as to that
Forgive me for being crass here, but often when people say something like "this worked on my other machine" or "this worked yesterday" it often didn't or the code when it did work was correct
There's no reason for a cross platform language like Python to work on one platform but not another
I'm not blaming you of course it's just something common that I see
no i perfectly get you, when I said that it was more as a "this is a very weird circumstance something must have been different" rather than blaming python haha
it worked though
I have a sneaking suspicion I know the reason why it was working on mine
I already had a valid data entry on mongodb
That is?
and it seems like for some reason it was ignoring it because of that
idk why but its working now is the important part haha
thank you for the help, i appreciate it ❤️
yup
How would I go about making a bot that on command posts a random image from an archive that I made with a bunch of images
where theses images stored?
!local
Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:
# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")
# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
file = discord.File(f)
When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.
discord.Embed instances have a set_image method which can be used to set an attachment as an image:
embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png") # Filename here must be exactly same as attachment filename.
After this, you can send an embed with an attachment to Discord:
await channel.send(file=file, embed=embed)
This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.
you can use random module for select a random image from your folder, and send it to a channel!
Is discord.py still discontinued?
you can try something like that:
import os
import random
path="C:\\Users\\Desktop\\image"
files=os.listdir(path)
d=random.choice(files)
os.startfile(d)
there is to many ways to get the files from folder!
Alright thanks

How do you add an image to an embed
!d discord.Embed.set_image
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
just tried this and
yes, i'm only passing 1 url
url='something'
ohhhhh
How would i prevent my grouped sub commands from sending the main group command whenever i mistype the sub command?
async def rep(interaction: discord.Interaction, username1: discord.user):
how do I get username1 to be specified as a discord user, im using a slash command
type hint it discord.Member
wdym by that?
if ur talking ab stopping ur parent command from being executed when the sub cmd is you cant.
you can, you just have to set invoke_without_command=True in the parent decorator
thanks
oh nice
Is there a solution?
Read the first line
I have fixed it But it happened like this instead.
can u show code u doin something wrong
it's self, interaction, select/button
You have them the wrong way around
what should i do
change it?
oh thx you
the same with the selectmenu
this needs to be self.interaction...
not self.Interaction
actually that makes no sense
you don't have self.interaction defined anywhere 
Thanks, I'm a newbie so I don't know much haha
this typehint should be discord.Interaction
I fixed it and it didn't work. 😵💫
yeah because you haven't defined it anywhere
what should i do
I'm guessing you wanted to do self.ctx.message.edit
ctx.message.edit is the method you'll use to edit the message
instead of self.interaction.edit_original_response
discord.py isn't meant for beginners so it can get confusing if you're new to python
what's your code?
where are you defining self.message? I don't see it in the docs
Can you take a look at my code, it might be easier.
i don't understand it
also if u check dpy discord. you will find examples
class MyView(discord.ui.View):
def __init__(self, timeout):
super().__init__(timeout=timeout)
self.response = None # Define a variable named response with the initial value set to None
async def on_timeout(self):
for child in self.children: # We need to iterate over all the buttons/selects in the View (self.children returns a list of all the Items in the View)
child.disabled = True # And set disabled = True to disable them
await self.response.edit(view=self) # Now we just need to update our old message with the updated buttons
@bot.command()
async def foo(ctx):
my_view = MyView(timeout=30.0) # We need to create an instance of this class first, so that we can set the response to the returned message object
out = await ctx.send('on_timeout Example', view=my_view)
my_view.response = out # Here we're setting our `self.response` as the output message we got in return from .send()
if you dont understand i suggest taking a step back from discord bots and properly learning python
it's so hard
Hey @signal hedge!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Nah it easy you just need to put in sm effort to learn it
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
U can see places to.learn python for free there
thx u
https://paste.pythondiscord.com/atoremapug
Please see to me where I should fix it.
U made a mistake here
What do I have to change
switch the type hints of interaction and button
-
this part of code was not present in the copypaste link
-
you don't have an interaction attribute defined in the class and if you have defined it later than the copypaste link you should named it like
interaction, interaction with the upperiindicates a class (the Interaction class), instead interaction is an Interaction object
@bot.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def test(ctx):
await ctx.channel.send("command output")
@test.error
async def info_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.channel.send('there is a cooldown')```
I want the bot to tell how much time left for the cooldown
Anyone learning python from scratch?
me
@shrewd apex how's it man.
i gotchu homedawg
1 sec
learning a language is easy mastering it is tough
^
@slate swan
await ctx.channel.send(f"Try again in {error.retry_after:.2f}s.")
try this
oh k
ty mate
yw
@commands.dynamic_cooldown(cooldown_callback, commands.BucketType.member)
@app_commands.command(name="ping", description="Ping pong")
@app_commands.describe(hidden="Show message as hidden")
async def ping(self, interaction: discord.Interaction, hidden:bool=False) -> None:
author = interaction.message.author
how come message is NoneType here?
Python discord bot from another script address?
Hey, I have a Discord Bot, but it can't really do much at the moment, but I want to change that now. I want the bot to write a DM to a certain user with an ID, which comes from another script (Could be PHP or python, what you find better). So script 1 does a task, gets returned so to speak a Discord name/tag. An ID and to this name a DM with the respective ID should be written. Has who possibly an example code for me?
where can i go to host my discord bot 24/7
use a database
Hello, this server is for helping with errors and so on, we do not help users with full commands only fixing errors sorry
You can get a vps for really cheap
where is a tutorial to do that
do i just paste all my code into the vps
oracle cloud always free tier
just do research also stuff on youtube for hosting discord bots using it
you mean just upload something to a DB and the other script have a look up on the table and works with it?
the script store the user IDs in a DB and when the DB is updated have the bot take the data from the db and DM the user
they don't allow that in 2.0
used bot.start()
does discordpy prohbit commands.command in v2.0?
cz commands are not getting picked up
Okayyyy, sounds good
need help with pay command in #help-popcorn
what does this mean
The key doesnt exist in the dictionary
im trying to keep my bot alive by adding a background task
status = cycle(['with Python','JetHub'])
@bot.event
async def on_ready():
change_status.start()
print("Your bot is ready")
@tasks.loop(seconds=10)
async def change_status():
await bot.change_presence(activity=discord.Game(next(status)))
but it says cycle is not defined, anyone know why?
Import it
Are you using client or bot
bot
Then take a quick guess
@slate swan your suppose to use run function not login
I'm guessing you are a js dev lol
yes
client.run
Yea it's bot.run
How do you make a persistent UI button (one that still works after bot restart)
Client is if you had variable saved as client and not bot
how do i define cycle?
import cycle?
Specify timeout to none
!d discord.ext.commands.Bot.add_view
add_view(view, *, message_id=None)```
Registers a [`View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View "discord.ui.View") for persistent listening.
This method should be used for when a view is comprised of components that last longer than the lifecycle of the program.
New in version 2.0.
not work
Does timeout not do same function?
did you remove the ?
now it shows that
@slate swan dm me
im trying to do this: https://stackoverflow.com/questions/54722596/keep-discord-bot-online-on-repl-it
but cycle is not defined
How do I use repl.it for my Python Discord Bot, and keep it running 24/7.
I used to use keep_alive but it stops working for some reason.
Does anyone have any suggestions?
I keep getting this err...
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
This is due to you using repl, repl uses shares IPs, and there for when other people abuse the api on repl you suffer to
Does it have to be a specific message?
Do kill 1 in the console thing on repl
Repl is highly highly not recommend for hosting bots
whats recommended
And I saw your bot token is public which is also a risk
A vps or rdp
anyone know how to keep bot alive 24/7 on replit
uptimerobot
You can't really anymore, repl blocks it sometimes
i did this:
from threading import Thread
app = Flask('')
@app.route('/')
def main():
return "Your Bot Is Ready"
def run():
app.run(host="0.0.0.0", port=8000)
def keep_alive():
server = Thread(target=run)
server.start()
Also I'll keep repeating this argument repl isn't for hot hosting
idk how to setup vps
You buy one it's easy af to use
which one can i buy with crypto
Most of em accept crypto
did you import it and do keep_alive()
i just pasted all that into my main.py
noooo
add a file called keep_alive.py
and put this in there
from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def home():
return "Bot Online"
def run():
app.run(host='0.0.0.0',port=8080)
def keep_alive():
t = Thread(target=run)
t.start()
at the top of your code put
from keep_alive import keep_alive
ok thanks
then above your client.run or bot.run do
keep_alive()
How to turn off, that discord bot does react to direct message
If not message.guild:
await ctx.send("whoops this isn't in a server this is in dms")
where do i have to build it in?
idk, just want that the Bot dont react to dms
message.send not ctx sorry
My fault
if not message.guild:
return
else:
await client.process_commands(message)
to make dms unusable
O cool
yea
I don't use discord py very often I mainly use nextcord
As I don't really trust the devs not to drop the project again
activity = random.choice(random_activity)
await client.change_presence(activity=discord.Game(name=activity))
ppl still dont know you can do random statuses...
I do lol it's obvious
I feel like random should be built in function like js
eh
{"1031053618008301588": {"money": 1468, "bank": 5000, "totalmny": 1673}, "994474388042813450": {"money": 1536, "bank": 5000, "totalmny": 1536}, "950652516708782120": {"money": 1331, "bank": 5000, "totalmny": 1664}, "812729257968009256": {"money": 1500, "bank": 5000, "totalmny": 1500}, "1022261701850169445": {"money": 1500, "bank": 5000, "totalmny": 1500}}
economy bot lol
{"1031053618008301588": {"silverchest": 0, "goldchest": 0, "copperchest": 0, "fishingrod": 3, "sunfish": 14, "clownfish": 0, "nametags": 16}, "950652516708782120": {"silverchest": 0, "goldchest": 0, "copperchest": 0, "fishingrod": 1, "sunfish": 11, "clownfish": 6, "nametags": 8}, "812729257968009256": {"silverchest": 0, "goldchest": 0, "copperchest": 0, "fishingrod": 0, "sunfish": 0, "clownfish": 0, "nametags": 0}}
Why does it not work if i type in chat !foo test:
client = commands.Bot(command_prefix="!", intents=intents)
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.command()
async def foo(ctx, arg):
await ctx.send(arg)
I need help with someone separating my code on repl who can.
what are the intents
@main moth
the command will work but what are the intents
intents = Intents.default()
intents.messages = True
turn all 3 on
Okay
client = commands.Bot(command_prefix="!", intents=discord.Intents.all())
this will work too
its message_content , not message
The is the following error: AttributeError: 'Intents' object has no attribute 'message_content'
jus do this
when did you last update discord.py lol
do pip install -U discord.py
no, it doesn't work for him because he enabled only the message content intents, not all of them
o
I added all of them
well here it shows only one of them, but okay
he used mine i think
wtv gn
yeah but i have changed it
someone says
what have i to change
does discord require you to reinvite the bot after updating intents
!foo test doesnt send a message
i asked you to update discord.py and you did not
I just run pip install -U
and what about the discord.py?
i mean the discord.py
Yes i have an on_message event
change .event to .listen()
client = commands.Bot(command_prefix="!", intents=discord.Intents.all())
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.command()
async def foo(ctx, arg):
await ctx.send(arg)
@client.event
async def on_message(message):
if not message.guild:
await message.author.send("whoops this isn't in a server this is in dms")
return
if message.author == client.user:
return
if message.content.startswith('hi'):
await message.channel.send('Hello!')
thats what happens you watch tutorials online lol
reading doesn't hurt
but why?
client = commands.Bot(command_prefix="!", intents=discord.Intents.all())
@client.event
async def on_ready():
print(f'We have logged in as {client.user}')
@client.command()
async def foo(ctx, arg):
await ctx.send(arg)
@client.event
async def on_message(message):
if not message.guild:
await message.author.send("whoops this isn't in a server this is in dms")
return
if message.author == client.user:
return
if message.content.startswith('hi'):
await message.channel.send('Hello!')
F string better
And it doesnt fix the foo mistake?!
because an on_message event will block your commands
will change it
it does, you can either start listening to what others tell, or start reading the docs
much better than stupid old tutorials
🙂
i have a class rn so can't really, people here will help
okay
look at the FAQ in the dpy docs
Copy and pasting = very bad habit
yes yes
Copy and pasting = very bad habit
Correct
69% of current bot "developers": lol what
💀
How to fix?
The only reasonable way to copy something is if you understand the code
With wrench
tbh when i was first starting out i'd copy code, and the only way to know if you have the code you need and which part to copy is to understand it
We all did this lol
There are 2 things I copypaste: weird linux commands with tons of flags and paths and js effects
Bro that's repl lol
wha~ thats typescript/java import style!
Bro that's python 💀
its ```py
from x import y
Yes
Correct
i wanna use ?tag lp on you so badly
O yea I'm blind I just realised
In java there's no even such thing as from iirc
What do I replace?
This is not a Modmail thread.
?tag lp
This is not a Modmail thread.
You can either ```java
import java.util.Scanner;
Or
```java
import java.util.*;```
I'm stupid
I forgor the package anyway
Ik but what do I replace??
Golang only has import too
well, code has many issues
discord_slash is no longer maintained, use dpy for slash commands
what you using flask for? hosting the bot?
and replit is one of the issues itself
Making a otp bot.
lol its a RoboDanny command, the bot is not here
you'll see that often in the dpy server
My method is "never give food, teach to get food instead"
That's more efficient yk
ohh I wasn't really aware about that, might have confused it with some other language
uninstalled, I'm using manjaro with i3wm rn
Typically people who ask question "what to replace" when they get syntax error they are straight out from watching a youtube tutorial and retyping the whole code not understanding a thing
I didn’t get this off some yt tut.
Well what's your python knowledge
My friend gave it to me and said “make it work”
That's unrelated to my question
I know nth abt python 😪
Nice
send it back to him and say "works on my machine"
LOL
And how were you gonna code anything
dk.
Ingenious way
But what if he asks to send their machine 🧐
then you send a typewriter back
with the code carefully typed out on paper
😩
thats how docker was born
Is there really not a single way to get a Guild object from a guild id, no matter if the bot is in the guild or not??
With syntax highlighting 🥰
What do you need it for
I need it to get a Guild object from a guild id
there is not.
bot has to share the guild
This made my morning. I love it.
Then how does some websites fetch informations about a server they never been into?
if theyre doing that, they're doing it against discord's tos
users authorize to show what guilds they are in. but i dont know of anything that shows information on a guild without SHARING the guild in some way
which if they are, olie already mentioned prob doing something against discord tos
otherwise they might have stored info from previous users from that guild i guess
if not ctx.guild:
await ctx.author.send("whoops this isn't in a server this is in dms")
return
if ctx.author == client.user:
return
I do this on every command and on_messge. Should I do it in a different async function and call it from every event or is there an easier way to set it as default?
why? they use server widgets according to their explainations
what specifically are you referring to?
i have no idea what a server widget is?
I don't mean to get critical informations about a server, just the name and the pfp
unless they mean they have a bot in the server
this one
guys how can i make it so my buttons are under each other instead of next to each other
that is something that is simply done through users authorizing that bot to see the guilds they are in
no no wait
You can specify a row for your button location
i might do this by piggybacking off a site like top.gg and scraping their data
how ?
okay i'll check if the widget thingie can be implemented
With row= 1 in your button arguments
unless you need servers that are not listed publicly
ok
the widget is referring to the guild having a discord widget on a public website somewhere
yup
this is a widget btw, which if the server has it enabled, its pretty simple to get the data.
is there a way to store button clicks ? for example a button called 1 and another called + to like make it do 1 + 1
using a db.
another easier way is in the buttons custom_id
how do i store the clicks ?
or how do i use it with this
depends on use case though
yea probably easier this way if u dont plan on storing per user
?
just overall clicks
do you know how to make a button?
yes
and you defined a custom id for it?
not yet
Guys why i getting error
Cannot send empty message
This is my code - https://paste.pythondiscord.com/osugezezac
https://discord.com/api/guilds/929060332880674836/widget.json which u can get this data publicly if they again have the widget enabled.
button1 = Button(label="1", style=discord.ButtonStyle.success, custom_id="1")```
that id good ?
its fine if you want everyone to be able to press the button
yes
Chill there's like 9 people in here trying to get help lol
idk what u even mean by this?
are u trying to use a discord bot to send stuff to a cmd prompt??????
He wants a discord interaction to be able to open a new cmd tab on his PC to perform functions
then it's just new_custom = int(interaction.custom_id) + 1
and use that in the new buttons custom id
wait what ?
yes :D
do i use this in the button callback or where do i put it ?
run it in an asynio task
asyncio.create_task(coro, *, name=None, context=None)```
Wrap the *coro* [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine) into a [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") and schedule its execution. Return the Task object.
If *name* is not `None`, it is set as the name of the task using [`Task.set_name()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.set_name "asyncio.Task.set_name").
An optional keyword-only *context* argument allows specifying a custom [`contextvars.Context`](https://docs.python.org/3/library/contextvars.html#contextvars.Context "contextvars.Context") for the *coro* to run in. The current context copy is created when no *context* is provided.
The task is executed in the loop returned by [`get_running_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop "asyncio.get_running_loop"), [`RuntimeError`](https://docs.python.org/3/library/exceptions.html#RuntimeError "RuntimeError") is raised if there is no running loop in current thread.
Note
[`asyncio.TaskGroup.create_task()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.TaskGroup.create_task "asyncio.TaskGroup.create_task") is a newer alternative that allows for convenient waiting for a group of related tasks.
noiceeeee
the only issue is that the code won't wait for it to complete
So you're able to pull guild info from their default invite?
no, from their widget
Oh if they have it enabled. I see
It's disabled by default so i'll try to find another way
yeee i actually had no clue about it until just now lol

What data are you looking for ?
name / member count / icon / banner
The invite ep has that
i do know
but I'm looking to get these infos from a server id, without being inside it
like you'd find all these infos about a user even tho you're not friends and don't share any server
i can't believe those infos are kept so secret
You don't need to be in server for the endpoint I know
i think it's mostly because of their implementations of other features that make the guilds "public"
you can't get guild info without the bot sharing the guild
You can
no you can't lmfao
https://discord.com/invite/python go to that and inspect requests
unless you would like to be banned by discord
its becuase its a public server lmao
but that's if you have an invite
and they have discovery enabled
Fair enough
Incorrect my way doesn't need any of this I made a fresh server and tested it works
if you aren't on the server or don't have an valid invite link, you can't get them ^^
you literally can't
You don't need to be in server but link needs to be valid
thing is that I can't get invite links for servers from the id
you need perms to create an invite link
so for public servers it's possible, for small server it's nearly impossible
yea technically all servers are considered "private" unless they enable discovery
Fair enough
With my technique they need "invite permissions" or a vanity
Oauth2 guilds scope
And you don't do that with dpy
what's this?
talking about oauth2 with users to get a list of their guilds
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
you mean it's not available withing dpy but i can't code it myself right?
yeah I get you
Depending on your application you want to use requests or aiohttp
so that can allow me to get all the guilds from a user object without the bot being inside them?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
You will get access to this endpoint once user authorises using oauth2
I see
I'll try to implement this, it sounds like a good thing
thank a lot jammy 
there's discord-ext-ipc for that iirc
It's easy enough to done with requests imo
Hey, does someone know how I would use message.author.id inside a command event using discord.py?
NotFound: 404 Not Found (error code: 10062): Unknown interaction why do I randomly get this
I read that u have to somehow send a response to discord that you received the command and then handle it but
You took too long to respond to the interaction
!d discord.InteractionResponse.defer - If it needs to take more than 3 seconds, you have to defer it
await defer(*, ephemeral=False, thinking=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Defers the interaction response.
This is typically used when the interaction is acknowledged and a secondary action will be done later.
This is only supported with the following interaction types...
that's what I found but I didnt get type hinting for that 🤔
its still developed and the discontinued news is old
damn full on booster vibes
go make vid
how does user inputs work on discord py
does anyone know why discordpy doesn't show errors anymore
it seems like they r suppressed
do you use bot.start?
can someone help me
What do you mean
need help with unban discord.py
Discord.py 2? Have you set up logging?
@client.command()
async def shard (ctx):
await ctx.send(embed=em)
em = discord.Embed(
title=f"shards")
description = """A shard is formed from a dead elemental gem,so if a lightning gem is the one that died, you'd get a lightning shard,make sure to read the info on shards in the wiki to understand better
But what you need to know is below
Grades and prices
Grade 1(x5 boost):2 diamonds
Grade 2(x7 boost):3 diamonds
Grade 3(10x boost):5 diamonds"""
em.set_thumbnail(url ="a gif url")```
It tells me em is not defined idk why
It's not in the function?
@client.command(pass_context=True)
async def unban(ctx):
banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split('#')
for ban_entry in banned_users:
user = ban_entry.user
if (user.name, user.discriminator) == (member_name, member_discriminator):
await ctx.guild.unban(user)
await ctx.channel.send(f"Unbanned: {user.mention}")
On mobile atleast it looks as if em is being defined in the function locally
And you're trying to access it outside the function
oh I see what you're saying
Where do you see it defined? I can't see member defined there
@client.command(pass_context=True)
async def unban(ctx, *, member):
banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split('#')
for ban_entry in banned_users:
user = ban_entry.user
if (user.name, user.discriminator) == (member_name, member_discriminator):
await ctx.guild.unban(user)
await ctx.channel.send(f"Unbanned: {user.mention}")
doesnt work also
Do you get an error? If not, are you sure the for loop and if statement are running properly?
And have you considered unbanning by user id instead of by name and discriminator? Would be much faster
lucas tutorial moment
Is your unban command looking like this?
for ban_entry in banned_users:
user = ban_entry.banned_users
if (user.name, user.discriminator) == (member_name, member_discriminator):
...
Lucas' unban only works for banning people via their name#discrim, now, this way is not wrong, but there are easier ways of unbanning people, e.g.:
# Unbanning by ID only (converting the ID to a object using discord.Object):
await ctx.guild.unban(discord.Object(id = id))
# converting the given user to a User object by type hinting:
async def unbean(ctx, user : discord.User, reason = None):
Inspiration from d.py official server
but how do i get all banned members in list
why do you need that huh?
cuz i want to unban evveryone
not using disocrd id bruh
bannnedUsers = await client.get_bans(serverID)
for user in bannedUsers: ?
well thats not what your code was doing.
uhuh? there's no client.get_bans
Is there not?
you'll have to ```py
async for member in ctx.guild.bans:
await member.unban()
nope
Bro the abuse
its just unbanning members, not as abusive as tasks that update status in 5 secs each lol
how would i remove the title from an embed and then resend the embed with a new title?
Change the embed's title property
How would I do this tho, as there is no way to re set a discord title or remove one in discords api
code?
show code
@client.command(pass_context=True)
async def unban(ctx):
await ctx.message.delete()
for member in ctx.guild.bans():
try:
await member.unban()
except:
pass
!d discord.Guild.bans - it's an async generator, so, use async for instead of for
async for ... in bans(*, limit=1000, before=..., after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.11)") of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/latest/api.html#discord.BanEntry "discord.BanEntry").
You must have [`ban_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") to get this information.
Changed in version 2.0: Due to a breaking change in Discord’s API, this now returns a paginated iterator instead of a list.
Examples
Usage...
Or iterator if you will
@mighty yarrow "async for"
is that even a command
what do you think
2 people and the docs will lie?
can someone give me a example of you writing a number, the bot multiplies that number and show it in a embed?
you want to take the number with on_message, a command or
on message
ok, so just convert message.content to an integer with int(), multiply it and send it with message.channel.send
a specific amount?
yes
like a specific number of channels?
yes
use a for loop?
can you help me first with
for i in range?
sure
save the asnwer so i can put it in a embed
https://github.com/Rapptz/RoboDanny
intermediate level source
that's not enough information, can you explain what you need in more detail?
there's also https://github.com/Rapptz/discord.py/blob/master/examples/basic_bot.py
if you need something more barebones
No I mean the abuse to other members as a joke
well it asks this, however how do i make it wait for them to type something and it comes up in a embed @vocal snow
you can use Client.wait_for to wait for an on_message event
!d discord.Client.wait_for
wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.11)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.11)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.11)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
there are examples in the doc
what?
@bot listen
I really have no idea what you mean
im stuck at this for days
I'm just saying that if you want to wait for an on_message event to get a user's message inline you use this
umm im not sure why you sent this
there is a detailed description as well as examples in the doc

