#discord-bots
1 messages · Page 2 of 1
Not even discord api allows you to spam bans and all for some event.
My bad
hi guys
Maybe their intentions are just to make one of the bot they see in channels like sounddrout and all, but yeah even they break tos and shouldn't be allowed
rate my pfp
spam pinging the every role? yeah seems like lies to me.
the funny thing is he got the everyone role in the worst way possible
Lmao I know I've seen a few videos where they create a new server and plays games like "last to remain in server wins" and mass ban people.. Maybe they're not lying but it's definitely not allowed
I was about to say about default_role until I realised what's their actual intention lol
no
just use the guilds id

the everyone role has the same id as the guild 
guild.default_role ? even easier
Did they really try edit there code lololol.... Just tag mods to ban them next time xD
the funny thing is he forgot to remove the while True part🥴
anyways lets move our topics.
a command just to ping everyone?
.topic
Suggest more topics here!
wouldnt it be faster if they would just ping by them self everyone
Im still debating whether to move my discord bot into a database tbf... Just recently upgraded it to 2.0 and broke everything 😐 wasn't fun fixing it...
⭐just use disnake⭐
Database integration somewhat like django
nextcord🗿
haha nar, no need 🙂 discord.py is fine 🙂
like a database client?
Like a complete orm I'd say
But that's too overkill for most discord bots
.topic
Suggest more topics here!
that would be a pain
a prefix changer
A help command which don't ask you to go on their website 💀
buttons for better ratelimits and slash commands only so prefix clashing/collisions dont happen
better handling as well lmao
^ Such a pain to use arrow keys to navigate b/w commands (especially when you don't have them)
.topic
capybara command
W
like that sends a random img of a capybara
A button based calculator which (almost) works
.topic
Suggest more topics here!
no
will this work?
how to do time like that?
Anyone know how i send a message in every channel to grab users attention??
Would but helpful for my server
!d discord.Guild.fetch_channels
await fetch_channels()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves all [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel") that the guild has.
Note
This method is an API call. For general usage, consider [`channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.channels "discord.Guild.channels") instead.
New in version 1.2.
Than the await function??
yes
no
So how would i do that??
that get all channels in guild
Can you send a example here??
hm
Uhh isn't that just spamming?
Wait, why would you want to send a message to every channel?
How do we know your not going to put some malicious intent behind this message?
To grab my users attention and make sure my bots moderation works...
thats all just why.
Well even if they prove it's still malicious and abuse of the api
I can't understand how mentioning everyone, spamming in every channel, mass ban is "moderation" related
maybe he should be banned
too sus with all these questions
does anyone know how I can get all of my users credit card details it's for my mod bot
helping a user with a nuke bot?
credit card details 😳
async def on_message(msg):
if any(word in msg.content for word in code):
await ctx.send('Correct!', delete_after=15)
member = msg.author
role = get(member.guild.roles, name="NPC")
await member.add_roles(role)
await ctx.send('Gave Role', delete_after=15)
await ctx.send('Removing Role In 5min', delete_after=60)
await asyncio.sleep(3)
await ctx.send('Removing Role In 1min', delete_after=15)
await asyncio.sleep(3)
await member.remove_roles(role)
ctx isnt defined
please help me its 3 am
idk why does he need it
on_message(msg) < no ctx
then how do i send message
Because ctx isnt. events don't have context passed, instead they have their own parameters
<@&831776746206265384> @cold tide keeps asking for help with an obvious nuke bot, the whole conversation is againsts tos and should end already.
he wants to iterate through all the channels and ping everyone its clear.
how do i send message without ctx
msg.channel.send
await msg.channel.send('Removing Role In 1min', delete_after=15)
like that?
agree'd needs the good old banhammer
at first I didn’t fully understand why he did this ... sorry
kick boot
tryy n see
.topic
i cantttttt
I was kinda trying to defend them before with that event bot but now it seems too sussy to be just that 💀
on_message has discord.Message as it's parameter
use that to send the message
how to do time like that?
!d discord.Message
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the message’s hash.
Wdym by "like that"? Please elaborate
AHHHHHHHHHHHH I CANTTT ITS REACTING TO ITS SELF AND ITS GIVING ITS ROLLE TO Its sELf
Kill meeeeeeeeeeeeeeeeeeeepuidvkjns;a 😢
i cant do this i want to sleep
🚫
Thanks, we've taken note, it seems they have already left of their own accord
I got there user id if needed?
Thank you.
so that the bot is selected time as it shows the discord when assigned to create a message
I can also right click myself
and logs are a thing lol
You mean the popup on hover thing?
yes
Imagine just trying to be helpful.
That's a discord's ui implementation. I don't think you can do that?
await ctx.guild.create_text_channel(name="General") throwing indent errors even thought its indented
This requires us to see some part of code above and below the line and possibly the error too
Okay
@bot.command() @commands.has_role("mod") async def backup_command(ctx): await ctx.guild.create_text_channel(name="general")
Throwing errors but idk why
@bot.listen()
async def on_message(msg):
if msg.author.id == 929946521133264938:
return
elif any(word in msg.content for word in code):
await msg.channel.send('Correct!', delete_after=15)
member = msg.author
role = get(member.guild.roles, name="NPC")
await member.add_roles(role)
await msg.channel.send('Gave Role', delete_after=15)
await msg.channel.send('Removing Role In 5min', delete_after=60)
await msg.channel.send('Removing Role In 1min', delete_after=15)
await member.remove_roles(role)
i.. so so close please just teach me
how do i make the bot add the role to the user and not the bot
FRICK IT im making it a fixed user
Your indentation might be off from somewhere else too.. Prefer sending more lines if possible
very more ez but i still dont know how to do that
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
if member.bot:
```?
what..
@slate swan it was the bot.run(token) that was out of ident ty tho
Np
maybe I didn't fully understand your question
you cant
Is this 929946521133264938 your bot id?
yes
like that too?
You add the role to a member not a user lmao
That's a different thing but yeah you can do that
WDYM I CANTTT
^
Not really different thing I just thought you meant to display time like how discord's ui displays it on the side of the username lol
you would fetch the member
!d discord.Guild.fetch_member
await fetch_member(member_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.
Note
This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_member()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.get_member "discord.Guild.get_member") instead.
Changed in version 2.0: `member_id` parameter is now positional-only.
member = message.912726263427383296
var = discord.utils.get(message.guild.roles, name = "role name")
member.add_role(var)
boom this would work first time right????????
Hi, what's the best free way to host your bot? (Not self hosting.)
@terse coyote https://gist.github.com/LeviSnoot/d9147767abeef2f770e9ddcd91eb85aa here you go check this gist out
Fields
i am trying to paginate send_cog_help, i got the buttons and all in place but i am getting troubled to create pages. here's what i do
async def send_cog_help(self, cog):
if len(subcommands := cog.get_commands()) == 0:
return await self.send_empty_cog_help(cog)
filtered = await self.filter_commands(subcommands, sort=True)
formatter = await HelpPageSource(
filtered, self, f"{cog.qualified_name}", cog_check=True
).format_page(self, filtered, 1, 1)
await Support().paginate([formatter], self.context)```how can i create pages
formatter is supposed to be a list of embeds here
i get all 27 commands in 1 page
expecting 6 per page
No any free way is best. Though there are partial-free ways like github education and azure/gcp trials. More about hosting in #965291480992321536
Yeah
^^
I think it's an embed_field but the second field doesn't have a title, maybe it's an invisible title with special char
Add another field in the same line with title being an invisible character
... ==
> ...
i am trying to paginate send_cog_help, i got the buttons and all in place but i am getting troubled to create pages. here's what i do
async def send_cog_help(self, cog):
if len(subcommands := cog.get_commands()) == 0:
return await self.send_empty_cog_help(cog)
filtered = await self.filter_commands(subcommands, sort=True)
formatter = await HelpPageSource(
filtered, self, f"{cog.qualified_name}", cog_check=True
).format_page(self, filtered, 1, 1)
await Support().paginate([formatter], self.context)```how can i create pages
formatter is supposed to be a list of embeds here
i get all 27 commands in 1 embed
expecting 6 per embed and list of respective embeds

If I'm not wrong, the <foo>? here denotes that the field can optionally be present in the payload and ?<foo> denotes that the value can also be None.. right? (Source: https://discord.com/developers/docs/resources/channel#channel-object-channel-structure)
The few times name will be null with the API is in cases of Group DMs
That why it is stated as nullable
Pls someone helppp I need 2.0 dpy on replit??? 🫂🫂🫂
How I can download dpy 2.0 on replit website
Ohkay... But in dpy types, they clearly type name variable for DMChannel too. So is that a bug or something else?
https://github.com/Rapptz/discord.py/blob/master/discord/types/channel.py#L47-L49
https://github.com/Rapptz/discord.py/blob/master/discord/types/channel.py#L129
discord/types/channel.py lines 47 to 49
class _BaseChannel(TypedDict):
id: Snowflake
name: str```
`discord/types/channel.py` line 129
```py
class DMChannel(_BaseChannel):```
Yes it isn't typehinted correctly to the API
But, that's not to say they SHOULD typehint it correctly here
How I can download dpy 2.0 on replit website?
Because it is out of scope for discord.py to even facilitate bots making group dms (which they can through Oauth2)
How I can download dpy 2.0 on replit website?
Typehinting it as NotRequired here would just yield annoying type errors when realistically not even possible to consider using the wrapper
Yeah that's right.. I think it should be fixed though just for the sake of consistency.. 
How I can download dpy 2.0 on replit website?
Please don't spam.. If anyone will know they'll just answer
Yes, but then for an example ```py
def on_message(message: discord.Message) -> None:
if message.channel.name.lower() == "foo": # Type error here even though realistically, never happens with DISCORD.PY
print("bar")
Consistency is nice but there is really no need for it to be fixed and it would just make typing in discord.py even worse
And discord.py already has enough type issues like, literally almost everything being generic
So when your using strict type checking with subclassing it gets suppper annoying with Unknown type
Yeah it's never going to happen anyways after all
I'm very new to type-hinting so I'm not gonna comment more on it lol
run in the shell the following command
pip install git+https://github.com/Rapptz/discord.py
btw you can read this in README.rst of Discord.py at the installation section https://github.com/Rapptz/discord.py/blob/master/README.rst#L49-L53
README.rst lines 49 to 53
To install the development version, do the following:
.. code:: sh
$ git clone https://github.com/Rapptz/discord.py```
@bot.command()
async def zrl_link(ctx):
embed=discord.Embed
file = discord. File("", filename="zrl_community_made_by_zahos.png")
embed.set_image(url="""https://cdn.discordapp.com/attachments/962040981589463183/1000331877695107143/zrl_community_made_by_zahos.png""")(title=">>> ZRL Server Invite Link ",description="",
color=000000)
await ctx.message.reply(file=file, embed=embed)
File "main.py", line 56
await ctx.message.reply(file=file, embed=embed)
^
IndentationError: unexpected indent
how can i fix this?
IndentationError: unexpected indent
it is saying you don't need the indentation there
So what do i change?
i wanna make a discord bot that can either read my minecraft server cmd logging or one that connects to the rcon of the server
is it possible to get the time of a song a user is muting in Spotify?
do u mean muting or pausing?
no, the time at which I listen to the song
how can i use the git clone command?
can u give me pls?
your code is hard to read like this, put it in a codeblock
place py or python in the first line and surround the text on either side with three backticks/backquotes (```) (see https://i.imgur.com/NmHjGsq.png).
The text is then coloured appropriately, making it easier to distinguish between different elements of your code.
print("Hello world!")```
The code you pasted is indented weirdly across the board, nothing is inside the function?
more of a git question than a #discord-bots one
how do i install git so i can clone a link?
can u give me link pls?
Ok
again, this isn't a question suited to #discord-bots
@bot.command()
async def zrl_link(ctx):
embed=discord.Embed
file = discord. File("", filename="zrl_community_made_by_zahos.png")
embed.set_image(url="""https://cdn.discordapp.com/attachments/962040981589463183/1000331877695107143/zrl_community_made_by_zahos.png""")(title=">>> ZRL Server Invite Link ",description="",
color=000000)
await ctx.message.reply(file=file, embed=embed)```
remove the whitespace after py
but yes, none of that code is indented inside the function
these need to be inside the function, currently they are not which is why python is tripping up at await ctx which is indented
Idk how to indent this im mew to dev
I'd strongly suggest reading up a bit more on python before going forward, indentation is super basic and important. You're going to trip up a lot if you're struggling with that
module 'discord' has no attribute 'ui'
how can I assign a role by id
role = discord.utils.get(ctx.guild.roles, id = your_role_id)
await member.add_roles(role)
this?
You're probably on v1.7.3. Update to v2.0.0^
Use guild.get_role(id) instead. It's O(1), while utils.get() is exponential. Also it's harder to follow along
oh yeah
2.0.0 very difficult for me
Hi, i made dank memer bot
do you need help
How do you make something that already exists 
How can I send a base64 encoded image to channel?
does anyone know why images render outside embeds from time to time?
for example
i used set_image for this btw
Hey so I have no idea how to make discord bot send webhooks with certain values to a certain channel.
Basically I want a command called +shout <arg>
and the discord bot use that command and send a webhook to a certain channel and the content of the webhook will be arg
i also want to change the values of the webhook like webhook username and pfp url.
if u can guide or help me achieve this i would really appreciate it but i have no idea where to start any help is appreciated thanks in advance
the output would look like this
https://cdn.discordapp.com/attachments/979896670554828840/1000542852348137502/unknown.png
how the webhook name and profile picture is the same as the ctx.author own
i'm new to python, pls help
what does this error mean:
if any(str(message.content).lower) == "slay"():
TypeError: 'builtin_function_or_method' object is not iterable
call str.lower
!d str.lower
str.lower()```
Return a copy of the string with all the cased characters [4](https://docs.python.org/3/library/stdtypes.html#id15) converted to lowercase.
The lowercasing algorithm used is described in section 3.13 of the Unicode Standard.
"slay"(): the brackets are used to indicate a function
👁️ 👁️
I figured it out
calling a string object🥴
SHHH I WAS DESPERATE 😭
lol 
What... I didn't even know you could call a string object, what does it do?
Oh it was a mistake, that makes more sense 
Hey so I have no idea how to make discord bot send webhooks with certain values to a certain channel.
Basically I want a command called +shout <arg>
and the discord bot use that command and send a webhook to a certain channel and the content of the webhook will be arg
i also want to change the values of the webhook like webhook username and pfp url.
if u can guide or help me achieve this i would really appreciate it but i have no idea where to start any help is appreciated thanks in advance
the output would look like this
https://cdn.discordapp.com/attachments/979896670554828840/1000542852348137502/unknown.png
how the webhook name and profile picture is the same as the ctx.author own
slay 💅
someone help me:
if msg.startswith("/masspingallowed"):
value = msg.split("/masspingallowed ",1)[1]
if value.lower() == "true":
db["masspingallowed"] = True
await message.channel.send("Mass ping is now allowed for the bot.")
else:
db["masspingallowed"] = False
await message.channel.send("Mass ping is now disabled for the bot.")
i made a mass ping command but i want to be able to turn it on and off. it returns this error when i tr it:
File "main.py", line 141, in on_message
user = msg.split("/massping ",1)[1]
IndexError: list index out of range
Please help
i figured it out
i had a command called
/massping
and my cmd to allow it was
/masspingallowed
and when i renamed it to /spampingallwoed
*allwoed
*allowed
it worked
print ("whats your pn?")
try to comment all your command
I dont even have made any slash command but it's showing
is there a way to make it return the full traceback of the error instead of just sending a little part of it?
@bot.event
async def on_command_error(ctx, error):
await ctx.send(f"An error occured: {str(error)}")```
You could use traceback.format_exception
from traceback import format_exception
@bot.event
async def on_command_error(ctx, error):
await ctx.send("An error occurred:\n" + "".join(format_exception(error.__class__, error, error.__traceback__)))
error.__class__ is like type(error)
ohh okay ty
would this be right if i want to put it in an embed?
from traceback import format_exception
embed = discord.Embed(
description=f"\`\`\`py\n{"".join(format_exception(exc.__class__, exc, exc.__traceback__))}\`\`\`",
)
await ctx.send(embed=embed)
No because you have "" in the {} but it's also the quotes of the f-string
so it would be ‘’ then right?
Use another type of quotes than "", yes
help
im getting an error while running my bot, it was a html code, i checked it and it says that i am banned from accessing discord.com
you've been banned by discord api 'cause you crossed ratelimits
run kill 1 in the shell and it'll reset the ip
oh
a major con in using replit :p
just ask
politer to ask to ask but ask without asking cz yes

!e
a = 'Ryuga\'s uwuness kills us all'
print(a)```
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
Ryuga's uwuness kills us all
til 3.11 is out
beta version
You can't use escape sequences inside a format in an f-string
it'll release sometime in october else december
well yes
https://media.discordapp.net/attachments/343944376055103488/1000319743158403103/Screenshot_2022-07-23-14-01-51-16.jpg
Guys why this error is coming
I dont even ahve a slash command but it's showing a slash command
Pls help me
@slate swan how do i add a reaction to a bot's msg?
i mean, the bot should add reaction to its own embed msg and then will do some stuff
Store message sent message in varibale
For ex
mes1 = await ctx.send("hello")
await mes1.add_reaction("❤️")
msg = await ctx.send('msg')
await msg.add_reaction('✅')
thanks
is the command showing up in ur server? did u sync?
I not even added any slash command
But it showing
Use bot.wait_for
will it loop if i add normal if statement
I can give example
oh
yes please!
You want that it waits for user to add reaction?
first of all it adds its own reaction then waits for user to add reaction
Ye
this is what im trying to do
react = bot.wait_for("raw_reaction_add", check=lambda p: p.message_id == message.id, timeout =20)
if react.emoji.name == "put any emoji here":
#do stuff here
Understood?
yes
At this
timeout = 20 means the bot wont respond if 20 seconds are passed right?
Ye
i really dont know whats wrong
Ok
Anyone here help me pls i asking from 2 days
a bot timing out a user?
you can timeout a member not a user
yes, i meant a member im sorry
await timeout(until, /, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").
You must have the [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") permission to use this.
This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit "discord.Member.edit").
all goodie 👍
thanks
👍
okimi, how long have you been programming for?
hi yall can yall gib me ideas on what to add to my bot?
about a year and 4 months👀
sheesh
oh wow very impressive 👀
im nothing like other regulars😅
a wallpaper finder with a horizontal and vertical wallpapers(images in an embed) and buttons to change wallpaper
Sheesh okii i'll try that later,thanks!
someone has done it but im not sure who, iirc it was scoopy
graph trends of server activity
react is a coroutine
can u speak normal
oh dont use this
:<
wot to use
ive seen the code from a yt tutorial and its bad
tell me what to use instead
shall i explain how a coroutine is made?
yes
code one yourself!
lol
bæn
-_
you wont learn anything if you just copy and paste
async def a():
...
here a is a function instance as its just being declared. when you call it
a # function obj
a() # coroutine obj
await a() # scheduling a coroutine and returning the caller when done
!d coroutine
oh
https://www.youtube.com/watch?v=Xbl7XjFYsN4&list=PLhNSoGM2ik6SIkVGXWBwerucXjgP1rHmB Is a good source for learning asyncio related stuff!
This series of videos introduces AsyncIO to Python programmers who haven't used it yet. The first episode is a high-level view on the async ecosystem. We cover:
- why you'd want to use asynchronous code at all;
- how latency drives the user experience;
- what the difference between concurrency and parallelism is;
- some of the problems you can...
when is the time to learn databases
learn them when you need them and when you feel ready
thanks
Can someone innocent help me
i actually need to learn how to use mongo but you can use mongo or sql
and i ment sql as an sql based db lmao
sql is fun to learn
it is, its quite easy to learn and handy non the less
can you show your code?
runestone academy is one of my favourite websites
https://sqlbolt.com is pretty good for learning sql ngl
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
Which part of code?
are you using slash commands and probably your command structure
discord.app_command.tree
if you're copying and pasting code then this is where your error is
probably made the tree of slash commands
well more like where its being raised
Ye
right haha
I never made a slash comamnd but still showing the command
did you made one before?
it kinda looks like a collision of states but im probably wrong, can you show your code?
BRO
have you tried disconnecting your bot from the gateway?
hLEP
👀
didnt derrick help you?
how do i know if a member has added reaction to an embed
sent by bot
opinion on making your own bot open source? like that everyone can see ur bots code

I like open source as you can let the community contribute to the beloved bot and read how it works and get inspiration and to know deeper about it
potential employers :D
oh okay
How?
and making your bot open source lets users implement commands that the community might want!
just closing the interpreter, it should zombify the connection
I daily restart my bot ;-;
if youre not messing with app commands then blame the API but to have a slash command to appear seems like youre registering/syncing your slash commands
this works?
no ;-;;;;;;;;
you need to register the event lol
;-;
why is it soo complicated
i just want the bot to send another meme when someone adds a reaction
😔
Discord.py is an advanced lib that uses OOP and async python, its not hard you just need to be experienced in python, you can always continue but it will be more easy for you if you learn OOP and async programming
¯\_(ツ)_/¯
.topic
i cant do this
i need to make a random number every time i run this function
and that random number needs to be used by another out side function
i want to make it run a function in side another function
but i cant do that cuz idk
you can always use that random number and return it on each call
wdym return it on each call?
when calling the function just return thst random number, do whatever with that number in the function and return that same number

it avoids the usage of the global keyword
💀
!e
def a():
return __import__("random").randint(1, 10)
print(a())
print(a())
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 1
002 | 7
return statement?????????
yes, just do whatever youre going to do with that random number and then return it to use it outside of it
!global
When adding functions or classes to a program, it can be tempting to reference inaccessible variables by declaring them as global. Doing this can result in code that is harder to read, debug and test. Instead of using globals, pass variables or objects as parameters and receive return values.
Instead of writing
def update_score():
global score, roll
score = score + roll
update_score()
do this instead
def update_score(score, roll):
return score + roll
score = update_score(score, roll)
For in-depth explanations on why global variables are bad news in a variety of situations, see this Stack Overflow answer.
ohh
wait.. what
@bot.command()
async def email(ctx):
await ctx.message.delete()
await ctx.send("Sending Email...", delete_after=15)
""""Random Number"""
range_start = 10**(4-1)
range_end = (10**4)-1
numb = randint(range_start, range_end)
body = 'Your Code: ' + str(numb)
code = str(numb)
await asyncio.sleep(2)
await ctx.send("Email Sent", delete_after=15)
score = whAT the fuck i dont undertAndT This
i just need it to carry on code and numb
why would you need the random number outside of the local scope and why are you using string concentation?
YO NEED Help
i have NO IDEA what thoes words mean sorry but all i need is that
create a random number each time i run the command
after i run that command another function will need the same number
async def email(ctx):
await ctx.message.delete()
await ctx.send("Sending Email...", delete_after=15)
""""Random Number"""
global numb, code
range_start = 10**(4-1)
range_end = (10**4)-1
numb = randint(range_start, range_end)
body = 'Your Code: ' + str(numb)
code = str(numb)
"""email function"""
em = EmailMessage()
em['From'] = email_sender
em['To'] = email_receiver
em['Subject'] = 'Code'
em.set_content(body)
context = ssl.create_default_context()
with smtplib.SMTP_SSL('smtp.gmail.com', 465, context=context) as smtp:
smtp.login(email_sender, email_password)
smtp.sendmail(email_sender, email_receiver, em.as_string())
"""email function"""
await asyncio.sleep(2)
await ctx.send("Email Sent", delete_after=15)```
sadly this didnt work
keeps saying that code isnt defined
Anyway how can I remove the command?
this command takes memes from a subreddit and sends it, it also makes sures that the meme is not a video.
(if its a video then it doesnt load in an embed)
but it is posting same memes after some times, how do i refresh it or get new ones?
async def email(ctx):
await ctx.message.delete()
range_start = 10**(4 - 1)
range_end = (10**4) - 1
numb = randint(range_start, range_end)
code = str(numb)
return code
@bot.listen(code)
async def on_message(msg):
await msg.channel.send('code', delete_after=15)```
does anybody know how to fix this
you haven't explained what neds fixing
im trying to call code in another function
but i cant
and im trying to recreate this:
test = 11
return test
def thing2(test):
if test == 11:
print(hi)
value = thing()
thing2(value)
you've passed code to the event decorator bot.listen
where.. should i pass it
wait im going to try to send it all here
@bot.command()
async def email(ctx):
await ctx.message.delete()
"""Random Number"""
range_start = 10**(4 - 1)
range_end = (10**4) - 1
numb = randint(range_start, range_end)
code = str(numb)
"""email function"""
return code
@bot.listen()
async def on_message(msg, code):
if msg.author.id == 929946521133264938:
return
elif any(word in msg.content for word in code):
await msg.channel.send('Correct!', delete_after=15)
member = msg.author
role = get(member.guild.roles, name="NPC")
await member.add_roles(role)
await msg.channel.send('Gave Role', delete_after=15)
await msg.channel.send('Removing Role In 5min', delete_after=60)
await asyncio.sleep(240)
await msg.channel.send('Removing Role In 1min', delete_after=15)
await asyncio.sleep(60)
await member.remove_roles(role)
await msg.channel.send('Removed Role Please Redo +email To Add Role Again.',delete_after=15)```
im making a random number in the first function
and the random number needs to update when i run the first function
and well basicaly i need to find a way to get the variable code out of the first function
!botvar
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
using command functions to return values is unusual. It won't work the way you want it to if you try to access code somewhere else
im not shure if this helps
welp time for option 2
is there any way for me to run a function inside another function like this for example:
def number():
range_start = 10**(4 - 1)
range_end = (10**4) - 1
numb = randint(range_start, range_end)
code = str(numb)
@bot.command()
async def email(ctx):
await ctx.message.delete()
number()
@bot.listen()
async def on_message(msg):
await msg.channel.send(code, delete_after=15)
it's not returning anything but yes
also if you want a variable that can be used across functions, and be able to change its value, the bot variable example is a good idea.
wait so is there no way to do this?
i could just replace listen with wait for and put it all in one function
but i have no idea how to do that and it would take 3 hours to do that
you aren't returning any value in this function
and even if it did, you aren't actually doing anything with it
but you could store the value of code in a bot variable and be able to use it in on_message
like this thing?
Yes
alright very nice
now.. how tf do i do that
man i have no idea how this works
aww hell naw
what is this
Are you referring to the typehint, the keyword-only parameter notation or the docstring
async def email(ctx, *, number: str):
await ctx.message.delete()
range_start = 10**(4 - 1)
range_end = (10**4) - 1
numb = randint(range_start, range_end)
code = str(numb)
code = number
@bot.listen()
async def on_message(msg):
if msg.author.id == 929946521133264938:
return
elif any(word in msg.content for word in number):
await msg.channel.send('Correct!', delete_after=15)```
will that work?
to make it a bot variable
im.. not shure..
no
You're looking at the wrong part
do you want a user to use a bot command called email and enter a string?
to be honest, this seems like a case of 'slow down and learn more python before progressing'
Hi I don’t really know if this is the place to ask but, I have been trying to make my discord bot attain a status on the music it’s currently playing in the voice channel like the example below, how would I get this to happen?
a bot variable = class variable
if you're familiar with classes it makes sense
!d discord.Client.change_presence
await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Changes the client’s presence.
Example
```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
``` Changed in version 2.0: Removed the `afk` keyword-only parameter...
it's ok not being an ass it's just
every step of the way you're going to hit a hurdle
getting up to speed on classes will definitely help
ohhh its abike
Corey Schafer has a good OOP tutorial on youtube
is print('An error has occurred!') being called?
well that's why then
request isn't being defined because it's hitting an error
subre.ddit < is it this perhaps
idk you're eating the error that's causing it
except Exception as e:
print(e)```
do this instead of that other print statement
but my brief reading of that code
makes me think it's because you wrote subre.ddit
instead of subreddit
ctrl+f
here
you didn't know what was causing it because your Except is making the actual error disappear
you're just accessing reddit's json, not using praw
it would appear that close isn't defined
is it in your code anywhere
are you copying this
I see
look for a def code somewhere in the place you're copying
it's hard to say without seeing the full thing but in general copy/pasting code will lead to issues unless you fully understand every part of it
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
there is no close function there
I'm assuming that code is missing something, I'm guessing Close() is meant to have some buttons in it or something
you could make that yourself, look up how to make buttons in your library
words = ['@everyone', '@here', 'test', 'Test']
@client.event
async def on_message(message):
if any(word in msg.content for word in words):
await message.delete()```
does anybody know why this does not delete all messages that has the words in words
(please ping me)
how can i add hybrid commands to jishaku cog
message, not msg
ohhh
words = ['@everyone', '@here', 'test', 'Test']
@client.event
async def on_message(message):
if any(word in message.content for word in words):
await message.delete()
welp i tried fixing it but it still does not delete the message if it has the word in words
still need help
usually it is just a decorator py @commands.hybrid_command(name="xyz")which you replace forpy @commands.command(name="xyz")
but here there's no commands.command
this wont.. break any of my code when i turn this on wil it?
nah just turn all the three on lol
alright i fixed it all i had to do was use
@bot.listen()
instead of
@client.event
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
@slate swan can you share the meme code
want to see button thing
The next meme button
you've made a group of slash commands usinf the random name and that is overwriting the random package import name
😩
inport random using a different name or chnge your slash group name
import random as rdm could be a fix and you do rdm.choice
**async def on_member_join **and ** on_member_join ** not returning anything with **await channel.send(embed=embed) **thoughts? They should be sending messages to my text channels but they are not? Not running into any error either . . .
member intents enabled?
Trying to play with cogs:
import os,random,discord,discord.utils,asyncio,datetime,time,asyncio
from discord.ext import commands
from discord.utils import get
class roomba(commands.Cog):
def __init__(self, bot):
self.bot = bot
bot = commands.Bot(command_prefix='.')
channel = ctx.message.author.voice.channel
@commands.guild_only()
@commands.command(pass_context = True)
@commands.has_role('Herra')
async def clear(self, ctx, amount=None):
if amount is None:
await ctx.channel.purge(limit=50)
elif amount == "all":
await ctx.channel.purge()
else:
await ctx.channel.purge(limit=int(amount))
def setup(bot):
bot.add_cog(roomba(bot))
In the name of holy simplicity: Why this does not work?
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.roomba' raised an error: NameError: name 'ctx' is not defined
Yes but when it is: discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.roomba' raised an error: TypeError: __init__() missing 1 required positional argument: 'ctx'
then you need to pass ctx when you instantiate the class
which doesnt really make sense
🤪
im not sure why you want to define channel in the init anyways...
defining bot again too, next level shit
probably not, this was very helpful
It is part of longer script, I think I had it for reason. now splitting it to cogs and it causes freakign headache...
My discord bot got some weird long JavaScript / HTML error even tho i made it in python, what's the problem? (My bot isn't starting)
have you used classes before?
If not, that's the reason for the headache
rate limit blockage by discord
nope
In how long will it be over?
do kill 1 in the shell cause replit
https://www.youtube.com/playlist?list=PL-osiE80TeTsqhIuOqKhwlXsIBIdSeYtc
if you're interested
import os,random,discord,discord.utils,asyncio,datetime,time,asyncio
from discord.ext import commands
from discord.utils import get
from discord import FFmpegPCMAudio
class clips(commands.Cog):
def __init__(self, bot):
self.bot = bot
bot = commands.Bot(command_prefix='.')
@commands.guild_only()
#Trynda
@commands.command()
async def trynda(self, ctx):
user = ctx.message.author
voice = get(self.bot.voice_clients, guild=ctx.guild)
channel = ctx.message.author.voice.channel
if voice and voice.is_connected:
await voice.move_to(channel)
else:
vc = await channel.connect()
time.sleep(.5)
path = "/home/pi/judge_dredd/cogs/mp3/imemunaa.mp3"
vc.play(discord.FFmpegOpusAudio(path), after=lambda e: print('done', e))
while vc.is_playing():
pass
await vc.disconnect()
def setup(bot):
bot.add_cog(clips(bot))
``` for some reason this works just fine
but TL;DR: the _init_ is called when the class is created, which you're doing in setup (roomba(bot))
corey 
because ctx is defined as a callback parameter
and the library passes ctx to it when the command is invoked
Oh thanks
not sure how to work intents or even what they are
intents are now enabled, still nothing | for some reason its not acknowledging new members
you've enabled the intents in the code and the developer portal?
yes on the developer portal and
**intents = discord.Intents.default() **
intents.members = True
can you share your full code?
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
try discord.intents.All()
doesnt make a difference
that would just enable presence and message_content intent if 2.0
and resource wasting
since that would enable unnecessary events to be received
Have a look https://paste.pythondiscord.com/veyaqamebe Kinda a mess!
what is line 132 supposed to do 🤔
you should remove that
Hello
Bro. How can I make a bot like disomegle
I don't know what disomegle is sorry
how do i make it so that when i click one button in that class, it disables ALL the buttons in that class?
can i get a time on which the song plays in Spotify?
omegle on discord?
Like in the view
yes
Is it possible to make a discord bot dashboard in django?
yes
what lib are you using?
can i get a time on which the song plays in Spotify?
pycord
Can you tell me how to make a bot like disomegle?
How to make a bot like when you react to a embed with button then bot opens a new channel
Like two buttons
One is two-on-two chat and second is group chat
So whenever user press those buttons a random channel will get open and how to set a limit so not more than 2 users enter in channel when
You can accomplish this by setting button.disabled to True in your button's callback. Then, you also would need to edit your original message to reflect this change.
Ayo, can someone tell me how I can put embeds in their own file so that I only have to load them into my main file?
new problems await channel.send(embed=embed)
AttributeError: 'NoneType' object has no attribute 'send'
😅
https://github.com/DisnakeDev/disnake/blob/master/examples/views/disable_view.py not a pycord example, but the method will be Exactly same since both of them are dpy forks
this was working just a moment ago lol
channel is None
you can create embed objects in other files and import them into your main one
like i import it to a var and await them?
you don't need to await embeds, do you?
i tried it and got the error discord.errors.InteractionResponded: This interaction has already been responded to before
can i see the code, it means that you already responded to the interaction once
turns out i was indeed passing it the wrong datatype, wants my yummyintegers
ah so I'll assume it's fixed now?
so far
I meant await ctx.send(embed=em1)
Import = form embeds import example
Var = em1 = exmaple.get_em1()"
nope
still not recognizing when someone joins the server tho 😦
super().__init__(timeout=None)
@discord.ui.button(row=0, label='Seller', style=discord.ButtonStyle.blurple, custom_id="trade_seller", disabled=False)
async def buyer_callback2(self, button, interaction):
await interaction.response.send_message(content=f"You have been successfully labelled as the **Seller**!", ephemeral=True)
db = mysql.connector.connect(
host="",
user="",
passwd="",
database="")
mycursor = db.cursor()
mycursor.execute(f"UPDATE Auto set SellerID = '{interaction.user.id}' WHERE channelID = '{interaction.channel.id}'")
db.commit()
embed=discord.Embed(title="Who are you dealing with?",description="Please reply with your traders **Developer ID**",color=0x17A589)
await interaction.channel.send(embed=embed)
for child in self.children:
if isinstance(child, discord.ui.Button):
child.disabled = True
# make sure to update the message with the new buttons
await interaction.response.edit_message(view=self)
# Prevents on_timeout from being triggered after the buttons are disabled
self.stop()```
my_embed.py
import discord
my_embed = discord.Embed(...)
``` ```py
# main.py
from my_file import my_embed
# inside command
await ctx.send(embed=my_embed)
i like embeds
and what does the command look like?
they are pretty
command?
Yeah, always use them xD
ahh
@slate swan take a look at my problems too? 🥺
And we still cant send them😔
File "main.py", line 47
@client.command()
^
IndentationError: unexpected unindent
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
Can u show full code of the on_member_join part
i can try to help :(
i mean :)
@eternal fox check this out!
anyone know why i get the error discord.errors.InteractionResponded: This interaction has already been responded to before
i have fixed some other issues with it since first post but still does not do anything with on_member_join
get_channel can return None lol
get_channel probably returning None, im not sarth but okay
all get_* methods check cache and can return None
try to use fetch_channel instead
yees
it would've been so much better if it just raised an error explaining that
it would be so much better if they read docs🗿
the @client.command() thing is getting included in the class above, how do i fix it
imagine reading docs
all get methods scream the return type😭
most libs do that
class View(discord.ui.View):
@discord.ui.button(label="Next Meme", style=discord.ButtonStyle.primary, emoji="⏭")
@client.command()
async def meme(ctx):
async with ctx.typing():
subreddit = reddit.subreddit("indiandankmemes")
all_subs = []
hot = subreddit.hot()
for submission in hot:
all_subs.append(submission)
random_sub = random.choice(all_subs)
url = random_sub.url
name = random_sub.title
author = random_sub.author
upvotes = random_sub.score
if random_sub.is_reddit_media_domain and not random_sub.is_video:
em = discord.Embed(title = name)
em.set_image(url = url)
em.set_footer(text= f'''from r/indiandankmemes by {author} | {upvotes} upvotes''')
await ctx.send(embed= em , view=View())

make a callback for the button
wHat
override them 
async def button_callback(self, button, interaction):
await interaction.response.send_message("You clicked the button!")
had someone join my server with the fetch_channel instead, still nothing
if the function was running at all i should atleast get the print statement, instead nothing
im thinking that its not even recognizing the event int the first place
!intents enable these
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.
they are
he has intents lol
i do intentd
👁️ 👁️
where is discord.ui
;-;
wdym where is it?
if its not found you would need 2.0 lol
Traceback (most recent call last):
File "main.py", line 4, in <module>
from discord.ui import Buttons
ModuleNotFoundError: No module named 'discord.ui'
how do i have cool code boxes like this
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
how do i
!e
print('e')
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="Start",style=discord.ButtonStyle.gray)
async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
print(interaction.user)
@bot.command()
async def help(ctx):
embed = discord.Embed(title=f"Auto Middleman", description="Auto MM is a bot which can automate tasks like a normal middleman. You pay the normal fee, and we'll do it for you.", color=0x2f3136)
embed.add_field(name="How does it work?", value="Like mentioned before, you pay the fee, we only accept BTC payments but please private message Admins for other payment methods. The buyer will then send the amount of what you're selling to a throwaway address generated by us. Then you'd send whatever you're selling to the buyer the details and once the buyer confirms he got it, the money will be sent to a address u specify. Once u confirm u have received the noney, the deal is predicted as completed and the ticket will self destruct.")
embed.add_field(name="How much is the fee?", value="Nothing more than `0.00013 BTC`")
embed.add_field(name="How do I start a deal?", value="Simply click the button below and the instructions will be in the ticket you create.")
await ctx.send(embed=embed)
``` im expecting for it to send the embed but instead it does nothing. nothing prints out in the console when i run btw
@client.event
async def on_member_join(member):
print(f"{member} joined the server!")
channel = client.get_channel(int(os.environ['WELCOMEMAT']))
await channel.send(f"{member} has arrived on the coast!")
#logging new members
logs = client.fetch_channel(int(os.environ['LOGS']))
embed = discord.Embed(title=f"{member} has joined the server!")
await logs.send(embed=embed)
this should do something
python -m pip git+https://github.com/Rapptz/discord.py
and yes you would need git
nvm i will use pycord

wait
help please!!
you named the slash command group random
which overwrites the name of the builtin lib random
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="Start",style=discord.ButtonStyle.gray)
async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
print(interaction.user)
@bot.command()
async def help(ctx):
embed = discord.Embed(title=f"Auto Middleman", description="Auto MM is a bot which can automate tasks like a normal middleman. You pay the normal fee, and we'll do it for you.", color=0x2f3136)
embed.add_field(name="How does it work?", value="Like mentioned before, you pay the fee, we only accept BTC payments but please private message Admins for other payment methods. The buyer will then send the amount of what you're selling to a throwaway address generated by us. Then you'd send whatever you're selling to the buyer the details and once the buyer confirms he got it, the money will be sent to a address u specify. Once u confirm u have received the noney, the deal is predicted as completed and the ticket will self destruct.")
embed.add_field(name="How much is the fee?", value="Nothing more than `0.00013 BTC`")
embed.add_field(name="How do I start a deal?", value="Simply click the button below and the instructions will be in the ticket you create.")
await ctx.send(embed=embed)
``` im expecting for it to send the embed but instead it does nothing. nothing prints out in the console when i run btw
you didnt do anything with Buttons
you need to make an instance and send it
like
view = YourViewClass()
await ctx.send(..., view=view)
Ah
still no work
import discord
from discord.ext import commands
intents = discord.Intents.default()
bot = commands.Bot(command_prefix='!', description='Auto MM made by xences and floppa', intents=intents)
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="Start",style=discord.ButtonStyle.gray)
async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
print(interaction.user)
@bot.event
async def on_ready():
print('Ready!')
async def help(ctx):
buttons = Buttons()
embed = discord.Embed(title=f"Auto Middleman", description="Auto MM is a bot which can automate tasks like a normal middleman. You pay the normal fee, and we'll do it for you.", color=0x2f3136)
embed.add_field(name="How does it work?", value="Like mentioned before, you pay the fee, we only accept BTC payments but please private message Admins for other payment methods. The buyer will then send the amount of what you're selling to a throwaway address generated by us. Then you'd send whatever you're selling to the buyer the details and once the buyer confirms he got it, the money will be sent to a address u specify. Once u confirm u have received the noney, the deal is predicted as completed and the ticket will self destruct.")
embed.add_field(name="How much is the fee?", value="Nothing more than `0.00013 BTC`")
embed.add_field(name="How do I start a deal?", value="Simply click the button below and the instructions will be in the ticket you create.")
await ctx.send(embed=embed, view=buttons)
bot.run('')
@paper sluice
you didnt decorate help with bot.command()
you should be subclassing HelpCommand for a help command
thats the recommended method
is it required
nope
but as far as i know using normal @bot.command() is discouraged for a help command
how do i subclass it
still doesnt work
import discord
from discord.ext import commands
intents = discord.Intents.default()
bot = commands.Bot(command_prefix='!', description='Auto MM made by xences and floppa', intents=intents)
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="Start",style=discord.ButtonStyle.gray)
async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
print(interaction.user)
@bot.event
async def on_ready():
print('Ready!')
@bot.command()
async def baron(ctx):
buttons = Buttons()
embed = discord.Embed(title=f"Auto Middleman", description="Auto MM is a bot which can automate tasks like a normal middleman. You pay the normal fee, and we'll do it for you.", color=0x2f3136)
embed.add_field(name="How does it work?", value="Like mentioned before, you pay the fee, we only accept BTC payments but please private message Admins for other payment methods. The buyer will then send the amount of what you're selling to a throwaway address generated by us. Then you'd send whatever you're selling to the buyer the details and once the buyer confirms he got it, the money will be sent to a address u specify. Once u confirm u have received the noney, the deal is predicted as completed and the ticket will self destruct.")
embed.add_field(name="How much is the fee?", value="Nothing more than `0.00013 BTC`")
embed.add_field(name="How do I start a deal?", value="Simply click the button below and the instructions will be in the ticket you create.")
await ctx.send(embed=embed, view=buttons)
bot.run('xx')
wdym doesn't work?
still doesnt send the embed wehen i run the command
take a look at this message
#discord-bots message
this should work right?
so if i ran !help it would still work?
what did you type for running the command?
!baron
enable message_content intent
intents = discord.Intents.default()
bot = commands.Bot(command_prefix='!', description='Auto MM made by xences and floppa', intents=intents)
```?
its on in the discord developer portal
intents.message_content = True
add this
works now @paper sluice thank u!
print(interaction.user)
AttributeError: 'Button' object has no attribute 'user'
interaction here is you button object so just change the arguments names around
change the interaction argument to button and the button argument to interaction
I want to make a bot that will send a message when a twitch stream started and when the stream went offline
What would be the better way to do it than scraping the twitch stream page every couple minutes and checking that way
Atleast tell me what it is called when you do a click on button and it opens a channel where two users can only enter once they press the button if more users press it then it makes a new channel for other users but limit is 2 only
duo private rooms
that's not a disord.py error
No.. I mean how to make it
create persistent buttons, then check for channels with your logic if the channel created already has 2 users, create a new one
Can you please. Tell me. And guide a little. Just a little. I will send you the server where the bot is just guide me a little on how to make it. I didn't me give me the code. I mean guide me a little so I can get a good idea. Plss
😔
check jmm
mhm im off for now, someone might help you by then else I will but later
convert to rgb before applying filter
!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.
bot = commands.Bot(command_prefix="!", intents=intents)
this passes intents to the bot? only on commands? what about @client.event ?
intents are just for the bot to be able to recieve events/data on the gateway
client.event can create handlers for these events. the commands module requires message data in order to parse commands.
In this case, I asume you mean bot.event
ok ok this. i think my bot is not getting the event
@client.event
async def on_member_join(member):
print(f"{member} has joined the server!")
this event does not happen when a member joins my server
What is client defined as?
Because above you use bot
Or did you just copy that from the embed?
i am using this
client = commands.Bot(command_prefix=prefix, case_insensitive=True, intents=intents)
im going to test this again
client = Bot, yes
Isn't that the best naming convention?
File "main.py", line 23, in on_member_join
await channel.send(f"{member} has arrived on the coast!")
TypeError: can't send non-None value to a just-started coroutine
this is something
what the
did not happen before
I never saw that error lol
no
Send your whole code where this error happens
@client.event
async def on_member_join(member):
print(f"{member} joined the server!")
channel = client.get_channel(int(os.environ['WELCOMEMAT']))
await channel.send(f"{member} has arrived on the coast!")
#logging new members
logs = client.fetch_channel(int(os.environ['LOGS']))
embed = discord.Embed(title=f"{member} has joined the server!")
await logs.send(embed=embed)
fetch_channel needs to be awaited, but that's not where the error is somehow
logs = await client.fetch**^^^
or logs = client.get
omg thank you IT WORKS
using client.get
It was sarcasm but okay
Nice, everyone buying Nitro nowadays cz of the offer
Nice, global emojis
INSERT INTO `nitro_subscription` (user_id, is_active) VALUES (1234567890, true);
```😔
Lmao indeed
thanks😳
@slate swan, I've json files with languages, in there are {}, how do I format them, when I want to get the string?
what do u mean by format?
str.format(**json_dict)?
Not when u gotta unpack dicts

keyword is "Hey {}!"
desc = language.get(guildID=ctx.guild.id, keyword="text")
description=desc.format(ctx.author.mention)
Otherwise it's to much code
keyword is just a note
eh
okay, found it
not batters
async def tiktok(ctx):
if ctx.channel==1000764912580169778:
embed=discord.Embed()
embed=discord.Embed(title=f"{ctx.author} successfully generated tiktok info ✅",description="Check your inbox !",color=0xffff00)
await ctx.reply(embed=embed) ```
Can someone help tell me the issue???
!code please format your code properly and explain what is wrong
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
I cannot format corectly due to my device.
And ive come here to seek help finding the issue.
@paper sluice
what is wrong
, why do you think there is an issue with your code?
device shouldn't matter... backticks are available on mobile keyboards
so nothing is wrong then
The command doesnt run.
Thats the issue i just cant find whats stopping it.
@vocal snow
look for errors in your terminal
No errors show
you should compare ctx.channel.id instead of ctx.channel
It worked ty!
they added extra digit to ids now?
👍
is that bc my variable holds nothing??
embed2=discord.Embed() embed2=discord.Embed(title="🤖 Reaper Gen",description="Non-Premium Gen !",color=0xffff00)
embed.add_field(name="Instagram Generated Info:",value=random.choice(ig),inline=True)
await ctx.author.send(emb2=embed)
bot.run(token)
can anyone help?? When running cmd it doesnt dm you.
@paper sluice
ImportError: cannot import name 'InvalidArgument' from 'discord' (/home/container/.local/lib/python3.10/site-packages/discord/__init__.py)
Which embed do you want to send
because
It's BadArgument I think
wdym?
He got 2 embed2 var
oh right
Try from discord import BadArgument
just reove the embed2 = discord.Embed() @cold tide
kk
ImportError: cannot import name 'BadArgument' from 'discord' (/home/container/.local/lib/python3.10/site-packages/discord/init.py)
i have both discord.py and discord.py-slash-command for button components
Discord-py-slash-command won’t work with discord.py v2 anymore
Still no dm
ah ok, what do i use then?
i need to get the author of a button interaction
Discord.py has built in app commands
discord.ui
i migrated from discord.py 1.7.3 to discord.py 2.0a
the problem is in terminal it shows "Bot is online" but when i try to run commands it shows :
2022-07-24 20:49:05 ERROR discord.ext.commands.bot Ignoring exception in command None
discord.ext.commands.errors.CommandNotFound: Command "ping" is not found
any solution ? (note: i alr enabled message content intent)
so do i just remove the import?
did u declare it in your code?
yes
Yeah don’t use discord_slash
intents = discord.Intents.default()
intents.message_content = True
!d discord.app_commands.CommandTree
class discord.app_commands.CommandTree(client, *, fallback_to_global=True)```
Represents a container that holds application command information.
async def on_component(ctx: ComponentContext):
NameError: name 'ComponentContext' is not defined
@bot.event
async def on_component(ctx: ComponentContext):
await ctx.defer(
ignore=True
) # ignore, i.e. don't do anything *with the button* when it's pressed.
ticket_created_embed = discord.Embed(
title="Ticket Processed",
description=f"""Hey {ctx.author.name}! Thanks for opening a ticket with us today. Let's continue""",
)
overwrites = {
guild.default_role: discord.PermissionOverwrite(view_channel=False),
ctx.author: discord.PermissionOverwrite(view_channel=True),
guild.me: discord.PermissionOverwrite(view_channel=True),
}
ticket = await deals_cog_2.create_text_channel(
f"{ctx.author.name}-{ctx.author.discriminator}", overwrites=overwrites
)
await ticket.send(
ctx.author.mention, embed=ticket_created_embed
) # ping the user who pressed the button, and send the embed
have you imported it or defined it somewhere? It's not part of dpy afaik
Hello bro. I made embed bot and send embed. Can you tell me now how can I edit that embed?
afaik?
as far as I know
.
Hello..?
!d discord.Message.edit
await edit(*, content=..., embed=..., embeds=..., attachments=..., suppress=False, delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
pass the new embed to it ^
I mean I already send the embed from bot. So I still can edit that?
By putting await edit under it?
@vocal snow
not sure what you mean
message = await ctx.send(embed=embed)
embed.description = "edited description"
await message.edit(embed=embed)
``` is an example
Bro I mean. I made an embed bot and send the embed already so now I want to edit it and want different once. So I can do it right ?
Without deleting that embed
yes
Ok
Also bro I made a embed page so it changes when you press the button. Will it still work if bot is offline?
no, it will not
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.musicc' raised an error: CommandRegistrationError: The command leave is already an existing command or alias.
Bruh
I cant add a new cog to my bot
Is there a way i could make my bot report to discord like something againstTOS ?
you have a command named leave and in the cog musicc, you made a command named leave, probably rename it
@bot.command()
async def toss(ctx):
embed2=discord.Embed()
embed2=discord.Embed(title="Heads or tails ?",description="Flipping coin...",color=0xffff00)
time.sleep(1.3)
embed2.add_field(name="It Landed on:",value=random.choice(flip),inline=True)
await ctx.send(embed2=embed)
bot.run(token)
i need help cmd isnt sending...
is there a way so the reaction roles would still work after restarting the bot? cause it stops working after i restarted the bot
Is there a way i could make my bot report to discord like something againstTOS
the keyword argument is called embed not embed2
Ahhh
oh nvm
So what should it be??
embed=embed2
I can't have a command names leave?
you can't have two commands with the same name
you already have a command called leave, you're trying to add another one
do you know how i can grab the author from button interaction
!d discord.Interaction.user
The user or member that sent the interaction.
consider using Buttons, you'll be able to make persistent views
how can i use that for my code? sry im bad when it comes to docs
in the callback, you just do interaction.user
ah yes just found it
Thanks for the help
I've never used buttons before so how can i make those?
just make the timeout on the view None
oh nvm, i think i misunderstood the question
is there a event or something?
Is there a way i could make my bot report to discord like something againstTOS?
For exam ple i say
?report
The bot responds with "message link:"
And when i type the message link
The bot responds with "What reason (then like the reasons you report for"
And then sends the report to discord
how are you making your buttons? can you send the code?
the button callback...
not really
Discord doesn't allow automated reports
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="Start",style=discord.ButtonStyle.gray)
async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
print(interaction.author)
ya, just replace interaction.author with interaction.user
alr
So you cant like get your bot to r eport stuff by emailing the support team
also, interaction comes before button, so the order is self, interaction, button
alr ty
ticket = await deals_cog_2.create_text_channel(
AttributeError: 'NoneType' object has no attribute 'create_text_channel
deals_cog_2 is None
deals_cog_2 = discord.utils.get(guild.categories, name=deals_cog)
Can someone tell me how this works?! How does bump reminder See it, that I was bumping... I thought you can't read interactions that go to another bot
guys can anyone help me
it probably just uses on_message and checks if the author is that bot
and maybe if it's sending an embed and some regex
When making a play command I keep on getting nonetype. Object has no attribute play
@app_commands.command(name='play',
description="Test Play")
async def play(self, interaction: discord.Interaction):
server = interaction.guild
voice_channel = server.voice_client
if not voice_channel: # if client isn't connected to any VCs
user_vc = interaction.user.voice # get user's voice state
if not user_vc: # if user isn't connected to any VCs
await interaction.response.send_message("You are not connected to a voice channel")
return
destination = user_vc.channel
await destination.connect()
audio_source = discord.FFmpegPCMAudio('song.oog')
voice_channel.play(audio_source)
await interaction.response.send_message("Playing")```
So i made a self bot (just for educational purposes) and what it does. when i ,test it will send a specific message to a specific channel , how can i make it send that message to multiple channels until i input something like NO
And what about the @?
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
is on_invite_delete triggered when an invite is deleted only or does it also trigger when an invite expires?
it's still against discord's ToS even if you are doing it for "educational" purposes
bc id like to do a lvl system about using bots...
alrighty lets predent its a real bot, how do i make it send that message to the channels i input
thats true... maybe disboard has an api?
^
just for a bot 
id recommend stopping before a mod comes along and notices
deals_cog_2 = discord.utils.get(guild.categories, name=deals_cog)
!d discord.Message.interaction
The interaction that this message is a response to.
New in version 2.0.
and use .user on it
await ctx.defer()
``` at the start, then `await ctx.followup.send` instead of ctx.respond
im guessing it takes more than 3 sec to generate your imag
also uh, you should handle the pillow stuff in a seperate thread probably
does anyone know how to use Rcon from a minecraft server to interact with a os discord bot?
?rfdm wait_for()
Python does have a few libraries for that, worked with a few
But this isn’t the right channel for that
robin u talking to me?
hello? ^^^
Yeah
which channel is it i wanna ask?
It’s sort of niche so you’ll wanna open up a help channel
i did yesterday but noone said anything
at this point imma just give up
ive been working on this for wayyy too long
17 hours a day for 3 days
got nowhere
@humble fog a quick search for “python Minecraft rcon” shows up many results
:/


