#discord-bots
1 messages Β· Page 801 of 1
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.9)"). 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.9)") 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.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
pretty sure that returns when the account was created @west shuttle
I want it in the format 1/8/2016 and not <built-in method timestamp of datetime.datetime object at 0x0000022D732B0C90>
Either use Discord's time formatting or if you want to make your own format use .strftime
Cuz .timestamp() is just a number
yeah strftime'
!d datetime.datetime.strftime
datetime.strftime(format)```
Return a string representing the date and time, controlled by an explicit format string. For a complete list of formatting directives, see [strftime() and strptime() Behavior](https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior).
ahh there it is'
Double datetime 
so like
em.add_field(name="Member created at:", value=member.created_at.strftime())
```?
You need to pass a format to strftime
Like "%H:%M" does 04:51
q = {
"question" : [],
"options" : [],
"answer" : []
}
question = q["question"]
options = q["options"]
answer = q["answer"]
@client.command()
async def ttrivia(ctx):
await ctx.send("Input your question here")
rresponse=await client.wait_for("message", timeout = 30)
if rresponse.content.endswith("?"):
await ctx.send("Your response has been stored")
else:
return await ctx.send("Entry denied")
await ctx.send("Input your options here")
rrresponse=await client.wait_for("message", timeout = 30)
if rrresponse.content.endswith(""):
await ctx.send("Your options have been recorded")
await ctx.send("Insert your answer here")
rrrresponse=await client.wait_for("message", timeout = 30)
if rrrresponse.content.endswith(""):
await ctx.send("Your answer has been stored")
question.append(rresponse.content)
options.append(rrresponse.content)
answer.append(rrrresponse.content)
@client.command()
async def quiz(ctx):
await ctx.send(random.choice(question))
answer_to_quiz=await client.wait_for("message", timeout = 30)
if question==answer and question==answer_to_quiz:
await ctx.send("Your answer is correct")
else:
return await ctx.send("Your answer is wrong")
@client.command()
async def dict(ctx):
await ctx.send(q)
!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.
can someone explain why the quiz is saying that answer is wrong?
Because you're comparing a message object to an empty list
these variable names lmfao
so like
%D/%M/%Y
day/month/year?
Well, there is append which adds questions options and answer to list
Lowercase the d and m
Oh ok
A quick reference for Python's strftime formatting directives.
thx
This has a cheatsheet
You're comparing if the question is the same as the answer and you're comparing if thr question is the same as a message object
guild = ctx.guild
role = discord.utils.get(guild.roles, name="Name-here")
get_role(role_id, /)```
Returns a role with the given ID from roles which the member has.
New in version 2.0.
!d if user.has_role
8.1. The if statement
The if statement is used for conditional execution:
if_stmt ::= "if" assignment_expression ":" suite
("elif" assignment_expression ":" suite)*
["else" ":" suite]
``` It selects exactly one of the suites by evaluating the expressions one by one until one is found to be true (see section [Boolean operations](https://docs.python.org/3/reference/expressions.html#booleans) for the definition of true and false); then that suite is executed (and no other part of the [`if`](https://docs.python.org/3/reference/compound_stmts.html#if) statement is executed or evaluated). If all expressions are false, the suite of the [`else`](https://docs.python.org/3/reference/compound_stmts.html#else) clause, if present, is executed.
Doesn't exist
hmm
if role in member.roles```
where `role` is a discord.Role object , and `member` is discord.Member
It's member.get_role
Or that
and yea member.get_role is a thing too
π₯Ί
guys recommend me something to code
hack NSA
related to discord bot? or something in general?
...
Dutchy π
No 
discord bot
Economy bot, its a challenge for beginners if you are one
not a beginner tbh π
Make it anyways
Implement Your Own Voice Receive :DDD
I've seen dutchy somewhere
||make something like an annoying rickrole||
ah SRA
lol
u mean a voice transmission system using web sockets?
Uhhh, bot joins the VC, records user voice
haha got it
Go make edpy
something similar to what mee6 does
Go use it
I don't make discord bots anymore
and any projects general?
Smh
huh
wat?
make an API wrapper maybe
What
No thanks
wait u dont make bots anymore?
No
haha i c
Not many users
was for nightwolf tho
No thanks
still, wont hurt if you try making some stuff
Even worse is guilded imo
omg dutchy
Tf is this
(BTW this isn't #381963689470984203 just in case)
Average french platform
Let's keep things sfw please @slate swan
raises horrible syntax errors
guilded is kinda good except its even less secure than disc
I hate it. Only thing I like about it are the channel types
@client.command()
async def quiz(ctx):
await ctx.send(random.choice(question))
answer_to_quiz=await client.wait_for("message", timeout = 30)
if question==answer and answer==answer_to_quiz:
await ctx.send("Your answer is correct")
else:
return await ctx.send("Your answer is wrong")```
Whats wrong 
that's what, what's wrong
You're still comparing to a message object
what are you trying to do
its because you implemented it horribly.
show code
well, basically users create their own questions, options and answers which are added to 3 diff lists in a dictionary (appending)
and then
use sqlite...
!d discord.Message.content
The actual contents of the message.
the messages are appended
answer==answer_to_quiz -> str == discord.Message
How?
you are comparing an string object with a discord.Message object
message.content is what u need
hmm
so i replace
no, i just represented those variables' classes
no?
hmm
you would be using message.content instead of message there
hmm
so answer_to_quiz.content?
πΆββοΈ
yea
lesgo
"Your answer is wrong"


!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 the Members and Presences intents, which are needed for events such as on_member 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.
Or sublime for the interface
is dat real nft or right click?
Right click snip snip save
bestieeeeeeee
Bestieeee
You think it's funny to take screenshots of people's NFTs, huh? Property theft is a joke to you? I'll have you know that the blockchain doesn't lie. I own it. Even if you save it, it's my property. You are mad that you don't own the art that I own.
Delete that screenshot.
LMAOOOOO
LOL IKR
FUNNY ASF AINT GONNA CAP
They be mad like uhh uhh we own that image, it's encrypted in the block chain
Dude I own this NFT. Do you really think you can get away with theft when you're showing what you stole from me directly to my face. My lawyers will make an easy job of this case. Prepare to say goodbye to your luscious life and start preparing for the streets. I will ruin you.
LMAPOOOOO
Man its such a joke
While funny we should probably keep talk in here on topic
Yeah
Virtual images are a joke
On topic
hmm
I'm trying to make a buy command for my economy
Keyboard warriors
yeah i was facing issue but people seem to have gotten tired of me cuz i cant seem to grasp the issue 
But it isn't working
Whatβs the problem?
lemme send
@client.command()
async def quiz(ctx):
await ctx.send(random.choice(question))
answer_to_quiz=await client.wait_for("message", timeout = 30)
if question==answer and answer==answer_to_quiz.content:
await ctx.send("Your answer is correct")
else:
return await ctx.send("Your answer is wrong")
q = {
"question" : [],
"options" : [],
"answer" : []
}
question = q["question"]
options = q["options"]
answer = q["answer"]
@client.command()
async def ttrivia(ctx):
await ctx.send("Input your question here")
rresponse=await client.wait_for("message", timeout = 30)
if rresponse.content.endswith("?"):
await ctx.send("Your response has been stored")
else:
return await ctx.send("Entry denied")
await ctx.send("Input your options here")
rrresponse=await client.wait_for("message", timeout = 30)
if rrresponse.content.endswith(""):
await ctx.send("Your options have been recorded")
await ctx.send("Insert your answer here")
rrrresponse=await client.wait_for("message", timeout = 30)
if rrrresponse.content.endswith(""):
await ctx.send("Your answer has been stored")
question.append(rresponse.content)
options.append(rrresponse.content)
answer.append(rrrresponse.content)
@client.command()
async def quiz(ctx):
await ctx.send(random.choice(question))
answer_to_quiz=await client.wait_for("message", timeout = 30)
if question==answer and answer==answer_to_quiz.content:
await ctx.send("Your answer is correct")
else:
return await ctx.send("Your answer is wrong")
@client.command()
async def dict(ctx):
await ctx.send(q)```
Here is the entire code for context
Try responding to the bot with the word message instead of yes and see what happens
Get rid of the:
if rrrresponse.content.endswith(""):
How would I code a bot that sends a msg after a certain time interval?
either use the tasks library or asyncio.wait()
I wasnt sure if it was trying to look for the specific word message instead of the message contents but thats not the case
ok
How do I make bots stay up for like a certain time then turn off lets say 9 hours
Do I need to host it with clou or whatever thingy what do I do
You'd probably use the tasks extension
Then when it's time to run, disconnect from the API
Dont I need to host on cloud
you can't fully turn off the bot unless you use some sort of bash script
you don't need to, leave your computer on for 9 hours if you want
I cant
I want to turn off my computer
then yes you'd probably need a cloud computer
a cloud computer will always be online whatever you do
yea if you use a vps you can
no don't use replit please
replit, is bad.
100%
Lets say I do it for like 6 hours
what to use
get a good host such as AWS EC2 instance
a vps
Computer on but replit website is close
btw gtg Im really hungry to eat sorry
t3.micro instances are super cheap and get the job done
well
it actually causes more issues now i think
can i make the bot ignore its own messages?
@zealous gorge use a task
Also @slate swan, all the questions and answers will reset when you turn the bot off and back on, you need to make sure you put a question back into the dict if you can
yeah i always readd them manually
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
Yes, i cant remember the exact syntax but just an if statement checking if the message sender is the bot and just returning nothing if it is should do it
In the quiz command, what's the question variable?
...
@bot.event
async def on_message(m):
...
if m.author == bot.user:
return
...
the question variable is question = q["question"] from the beginning
Are you sure that works within the function considering scoping?
Thats the one
as in? sorry cant understand
but they are using wait_for , so probably a check function is required.
Variables outside of a function won't work within
how do i go about doing that?
Looks like something's amiss with the if statement that checks if the answer is right
why if question==answer?
Mobile discord is nice but ass for anything actually code based
because if the question is
x and answer is y
x=y
So when the bot asks question via random.choice and the user gives the answer, the bot checks if the answer is equal to question
if answer is correct, it replies answer is correct
else, it gives wrong
I get your logic but the machine reads that code as if the answer is the same as the question, not if the answer to the question is the users answers
the questions and answers are stored within the lists
I think a datastructure like this would fit your needs best:
x = [
("This is a question", "This is an answer"),
("This is another question", "this is another answer"),
]
question.append(rresponse.content)
options.append(rrresponse.content)
answer.append(rrrresponse.content)```
Is it possible to make it so that when a participant left, it was written how long he was on the server in time? if yes, can you tell me how?
Help pls
I think if question.answer == answer should fix it
yeah that's what i was thinking
hmm
You can get the join date and the leave date, subtract the times together
man now its getting even more confusing to understand
As for going back to this just define the variables below the async def quiz
yes but the variables are supposed to be appended through previous commands
so if i define it below def quiz it'll cause error
How to subtract time?
Ah i see
And the time they left would just be datetime.datetime.now() would it not?
Sounds right
Therefore, the time now minus the join time = time in server
You can either just do normal integer subtraction using UNIX timestamps or use delta time
:thinking:
timedelta()
btw can you explain this a bit more?
Okay
Sure, it's a list of tuples, each tuple contains the question and the answer
I think in a situation like this it would have to be defined both within and outside of the function. The one inside the function would have to set its variables based on the ones previously set outside of it
oh so i should scrap the dictionary idea
how would i go about with that
oops
where did i goof up
oh i see
!e
x = [
("This is a question", "This is an answer"),
("This is another question", "this is another answer"),
("This is question 3", "this is answer 3"),
]
for question, answer in x:
print(f"Question: {question}")
print(f"Answer: {answer}")
print("-----")
@sick birch :white_check_mark: Your eval job has completed with return code 0.
001 | Question: This is a question
002 | Answer: This is an answer
003 | -----
004 | Question: This is another question
005 | Answer: this is another answer
006 | -----
007 | Question: This is question 3
008 | Answer: this is answer 3
009 | -----
hmm
but there's no way to store questions and answers from chat now is there
this'd mean that I would have to manually add questions and answers into the code
which isn't what im looking for
Not necessarily
The top half of that would be defined outside of the function and then a simple x = x inside the function should pull it in to be usable i think
!e
x = [
("This is a question", "This is an answer"),
("This is another question", "this is another answer"),
("This is question 3", "this is answer 3"),
]
q = "question 4"
a = "answer 4"
x.append((q, a))
print(x)
@sick birch :white_check_mark: Your eval job has completed with return code 0.
[('This is a question', 'This is an answer'), ('This is another question', 'this is another answer'), ('This is question 3', 'this is answer 3'), ('question 4', 'answer 4')]
you can put more questions in that way
hmm
!e
# accessing questions
x = [
("This is a question", "This is an answer"),
("This is another question", "this is another answer"),
("This is question 3", "this is answer 3"),
]
q1, a1 = x[1]
print(q1)
print(a1)
@sick birch :white_check_mark: Your eval job has completed with return code 0.
001 | This is another question
002 | this is another answer
hmm
guys any projects on discord bot ?
Would you suggest me to host my bot on repit or not? and why
not really
because your code would be public and anyone could see it
Yes but the Token is private
ok then there's no problem but replit is pretty slow sometimes
Its bad for ratelimiting people and doesnt have convenient 24/7 hosting
Where do you host your bots?
my bot isnt hosted yet:(
Its convenient for people who dont have coding ides and setting up a discord bot because it "doesnt need a host" but its seriously flawed in almost every aspect
a VPS
A lot of people get a VPS or use their own computer or an old one to just host it themself
is this free
AWS EC2
I used my Raspberry PI before that
not really, there are free ones but they're all bad imo
bad is being generous
I am struggling with finding good free hosting services
paradox much?
hi
"good free hosting services" don't exist sadly
yeah
Ive been hoing and humming about getting a pi, how useful are they for coding stuff? Would it be worth picking onw up sometime?
Though I think AWS has some amount of free hours? maybe give that a try
a vps is better than a rpi tbh if its for the long run the rpi is better
For sure! You can do all sorts of stuff on them, not just having them as a host. It was sort of like an intro into linux, and now I run arch on my main machine thanks to that
Do you know why do I get this error? I tried searching but still can't solve the problem
" Traceback (most recent call last):
File "C:\Users\filip\PycharmProjects\discordBOT\main.py", line 8, in <module>
@client.event()
TypeError: Client.event() missing 1 required positional argument: 'coro' "
code:
`import discord
TOKEN = "my bot token"
client = discord.Client()
@client.event()
async def on_ready():
print("Working")
client.run(TOKEN)`
I believe oracle has a free tier VM
how to get member with userId
problem with rpi is it doesn't scale
exactly
EC2 on the other hand, you can use their load balancers and scale easily
Also you don't have to worry about upkeep, electricity, internet bills, etc
i think you dont need the () after @client event
yeah which for the prize of a rpi you can get like 5+ years in some vps
depends on the plan
yea you don't
lol
t3.micro iirc has 2 gigs of ram and 2 cores? it should be good for a good while
thanks so much! i would never notice it haha
750 hours is still pretty good considering its free
(if you put linux on it of course)
so thats the error: @client_event does not need () after it
approx a month
no problem
yep
not bad
I mostly just use VMs to practice installing linux lmfao
ah wait it's each month
you practice installing linux?
if you have 6 hours of downtime each month you can get a full year of it
ofc
bruh
coures why would you not?
its fun when u dont have to care about loosing stuff
π
especially for a newbie like me
took me the better part of my saturday the first time i was installing arch on my main
meh i had to install mysql on kali today, i tried tons of times before realising that it comes with mariadb installed already
i only have windows cause some games doesnt support linux
mainly because i kept screwing up the partition tables and wiping all the data on the drives π
lmaoo
Im not ashamed to admit that i have to use guides for setting up linux vms
dual boot
i dual boot yeah
π§βπ¦―
or GPU passthrough with a windows VM
im not dual booting
lot of games support linux, or can be run through steam proton, same goes for some of the anti cheats
Epic's anti cheat for one
my laptop couldn't handle windows anymore so i just completely removed it, the only reason i had windows was games
which i dont play anylonger
anyways getting kinda ot here
.topic
Suggest more topics here!
more topics for this bot
okimii
@slate swan hows your stuff coming along?
ayo?π³
needs buttons
pretty messed up went through 7 stages of grief
gimme help command interface ideas
π
anything thats reactions that are used like buttons should be changed
Rip, want to open up a help channel so that we dont have to worry about other clutter coming up in here?
opened already lol
Ah aight, ill pop over there and try to help where i can
Well you can always contribute π
I have member id how do I turn it into memer variable to unban someone
!d discord.Guild.get_member
bot.get_user(id)
yeah
hey nova
If you have member ID you usually have the member variable
How did you get the ID?
Hey
You can use Guild.unban and pass in your User
I banned them now i can't unban without mention them
So i take use id to unban them
I'm using slash commands
guys any project recommendation on discord bots?
snake game
Yeah good point, you need to use an ID to unban
generic
use apis to make commands
generic
youre generic
something like R. Danny's help command without using menus
Your message is generic
stop
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.

A minecraft bot
hikari lightbulb's default help command does the same already :p
They weren't talking to you
ik but i am just curious
Their message was self-explanatory
π
User works too right
this is the default help command for hikari lightbulb :p
π
Whats up sar
not bad
ποΈ thinking of implementing a new help command
Looks pretty solid
π
its pretty decent as a default one
it also shows the slash commands
yeah
Image manipulation commands with pillow
hi andy
a command to add 3.9 ci to gh workflow
π
imagine using a default one π
i wish you could align everything so the embed buttons and drop down menu are the same size
how does that work
yea i tried pretty much like applying filters, merging images etc
!d discord.Guild.unban
await unban(user, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Unbans a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
Use discord.Object to make your own discord.abc.Snowflake
Since discord.abc.Snowflake is an abstract base class, you should never have to initialize it yourself
same
im just testing the library afterall, ill try making a custom help later
Well this is discord, not a web framework not is it?
(though honestly it's starting to become one)
you got a point but i wish we could
Reminds me I was totally gonna add a built-in http server to rin
you were gonna what
How's the rewrite going andy
@rin.GatewayClient.route("/guilds")
async def guilds(request) -> None:
...
Basically builtin discord-ext-ipc
weren't you guys going to use blanket's framework for that
no
and werent you gonna change the name cause people think rin is rin tohsaka
FastAPI
I dont know now
Wot I remember
What do you not understand?
wouldn't it return the function itself?
also has swagger ui!
I don't think it would here
Plus it's just psuedocode
Oh nevermind it would
you return the function itself in the function?
Actual impl would be like rin.GatewayClient.guilds
Subtract the date of departure from the date of joining
Although that isn't even right, since client has no way of getting guilds directly
it's returns are useless anyways, it going in void cuz of deco
Instead you'd need to use ```py
list(rin.Guild.cache.itertor())
βa cache iteratorβ
What's wrong with that
Just self.root.values()
could have used the iter dunder in base cache bozo
I could
The iter would need to return the cache, then I'd need to add __next__
then I have to do all this non-sense with keeping an index of the current element
Then I would actually need to handle stop iteration
requires another in-memory thing for me to do this
since dict have no index!
what is that iterator method even returning, a tuple of k:v?
yield from self.root.values()
It's a generator
oh
dont think indexing a dict would be possible since its dict['key']
Yep, you'd need to make a list of the values and keep track of index
Easy enough, but again
I am unbanned finally woho
Ok?
!rule 6 @slate swan
!rule 9 also
Lmao
why this isnt working?
@commands.command()
async def suggest(self, ctx, reason=None):
count_yes = int(1)
count_no= int(1)
count_yes_1 = count_yes + int(1)
if not ctx.channel.id == 933813622952562718:
await ctx.send("This command only works in #suggestions")
else:
if reason == None:
await ctx.send("You have to use ,suggest and then type your suggestion after ,suggest")
else:
button_yes = Button(label=count_yes, style=discord.ButtonStyle.success, emoji="β
")
button_no = Button(label=f"{count_no}", style=discord.ButtonStyle.danger, emoji="β")
view = View()
view.add_item(button_yes)
view.add_item(button_no)
embed=discord.Embed(title="Suggestion:", description=reason, color=13565696, timestamp=datetime.utcnow())
embed.set_author(name=f"{ctx.author.display_name} ({ctx.author.id})", icon_url=ctx.author.avatar.url)
message = await ctx.send(embed=embed, view=view)
async def button_yes_callback(interaction):
count_yes =+ 1
button_yes.label = count_yes
await message.edit(view=view)
Basically it should edit the button of the message and then set the number on the button 1 higher
But when I press the button nothing changes
It will stay 1
count_yes should't it be += 1
@fresh orchiddefine it as 0 first
>>> i = 0
>>> i += 1
>>> print(i)
1
>>> i =+ 1
>>> print(i)
1
>>> i += 1
>>> print(i)
2
>>>
count_yes = int(1)
Why are you using int()on it?
idk but i think this is not a problem
this happens cause you wanna += (addition) on a variable that is not defined yet.
and it is += not =+
that dosnt matter at all - and maybe he use to use another language that needs type defined varaibles
but it is defined
@fresh orchidIt is not. cause u define it in the first function not the inner function
what u would like to is more like use self. then
i dont think so because when I do
async def button_yes_callback(self, interaction):
self.count_yes += 1
button_yes.label = count_yes
await message.edit(view=view)
It says
missing 1 required positional argument: 'interaction'
i just know that =+ 1 is wrong its += 1
so no solution
i dont know no but it hink its weird that u cant use self
i hvntg played so much with inner functions or buttons for that matter
new error here self.count_yes += 1 button_yes.label = count_yes missing self on second
and yes message is not defined so thats another error
@fresh orchidmy friend, isnt your inner function in that else: block?
or is it just my screen
it should be same indentation as ur first varaible in ur upper function
one step at time π
weird python didnt say anything about that
(maybe u can have inner functions in if-statmeents i dunno
Still the same
I cant use Self
oh ok @fresh orchid can u reach the varaible count_yes now that u changed indentations? - if you remove self
how to dm everyone in server
hah gl with that @ionic ledge
why gl
i think thats borderline ToS on this server
we can do it in our private server right?
i mean ToS to help you with that
oh like this server wont help me with that?
si
It would bw fairly easy to do but morally i dont think anyone will help because of the damages it can cause
That's against the TOS and we can't help you with that, sorry
only with it is a spambot and thats a no go here
also violates rule 5
i need to use Google then ig
tbh, if you think about it it's really easy
at_everyone, at_here
a for loop, then some member stuff
not gonna give any specifics, it is against ToS
nice so you telling him when we all say its agianst TOS
@fresh orchidhows it going friend
let's not help them break TOS
what are some good libraries to work with slash commands
Disnake
@uneven apexdisnake
xD
no need to ping you
lol
You can work with slash commands with base discord.py pretty easily
They are considered interactions after all
@sick birchit dosnt take much effort to swap to disnake
and that fork is getting updated
No, but I'm only suggesting options
meh
If you want to use a fork you can, but nothing is forcing you to
ctrl+r and replace discord with disnake
but i didn't find anything regarding slash commands in its doc
then do some editing
Doesn't take to much to make a slash commands class, cache callbacks using id, then dispatching in INTERACTION_CREATE
Advice, never ask for help like that just ask your question and show whats wrong errors etc. ANd peopels gladly to help u if they can
that has nothing todo with discordbots
on_interaction will pick up slash commands, to register a slash command you just need to send an API request, which can be done using online tools such as Postman (excellent API testing tool)
In
No*
@fresh orchidsorry bro i cant help then π¦
All fine
@honest vessel no need to ping him every message
true but sometimes its just a habit
esp before the reply function was implanted
I used to ping people a lot back when I didnβt know python
say what? π
Its ok to ping me every Time
i mena when do like this no need ping but before u had this u had to ping
ping is now off
ur sweet
π³
it disturbed u but not him/her, thats whats funny.
You also know whatβs funny?
Tell me in a offtopic channel.
ok
can I send a couple pictures?
its a cyan color
i nvr used nextcord but try do a hex format and not a string
aka remove "
0xff0000 etc
will that work?
it complaining you sent a string so
I thought embed only had preset colours decided by (1,2,3,4,...) not any hex or other typical colour codes
wow discord.py accepts hex
ok let me try this now
if only preset colours to choose from wow stupid fork
@frozen patiotry remove " on it
i did
@honest vessel wtf
it crashed
lol
it needs to have the "
then its like he said ints, 1,2,3,4 preset
but u have also premade functions like Colour.blue()
etc i dont know exactly how they spell it but
im trying to put a cyan one in
!pypi discordheximals
returns hexcode by name for discord.py and its forks
π
@velvet tinselwhats ur issue?
thanks @slate swan
I dont have a issue
didnt work
which?
the python link
python link?
mhm
this what i use my oown dict of hex colours ```py
Colors for embeds
colors = {"blurple" : 0x7289DA, "green" : 0x33ff57, "yellow" : 0xFFD300, "red" : 0xB22222}
em = discord.Embed(title="", description="", colour=myclass.colors["blurple"])
i skipped the 0x thing yeah
try both let us know what worked
ok
this did
ah
d.py accepts hex tho
disnake too
how come they not fix so it accepts both ?
thank you 2 very much
np happy cayn
yep the command worked also!
@velvet tinselimagine not accept both how hard that can be ...
time for π΄ 

Get the Member object and use the kick method on it
!d discord.Member.kick
await kick(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.kick "discord.Guild.kick").
await ban(*, delete_message_days=1, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Bans this member. Equivalent to [`Guild.ban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.ban "discord.Guild.ban").
ok thanks!
Welcomeee
chemicals = dict()
index = 1
while True:
chemical = input(f"Enter chemical {index}: ")
if chemical == " ":
break
else:
chemicals[chemical] = input("Enter the amount: ")
index += 1
print(chemicals)
Yooooo. I found a way to have infinite QnAs π€€
hey
Hi hi
hi hi
and anybody can do a while loop lol
I'm gonna copy this code and use it in my bot
haha
So I'm trying to make a invite info command so read https://discordpy.readthedocs.io/en/stable/api.html?highlight=invite#discord.Invite to see all of the attributes but for some reason I'm getting this errorpy ERROR:cogs.error_handler:AttributeError: 'NoneType' object has no attribute 'timestamp' (In inviteinfo) Traceback: File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/info.py", line 478, in inviteinfo embed = discord.Embed(title = f"Server invite: {invite.code}", description = f"Invite created <t:{int(invite.created_at.timestamp())}:R>", colour = ctx.author.colour, url = invite.url) so I tries removing timestamp which also error'd withpy ERROR:cogs.error_handler:TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' (In inviteinfo) Traceback: File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/info.py", line 478, in inviteinfo embed = discord.Embed(title = f"Server invite: {invite.code}", description = f"Invite created <t:{int(invite.created_at)}:R>", colour = ctx.author.colour, url = invite.url)so I think timestamps supposed to be there based on my other info commands (roleinfo, serverinfo and userinfo) which all have created_at.timestamp(). This is my codepy @commands.guild_only() @commands.command(description = "Get some information about a invite.", usage = "inviteinfo", aliases = ["invitestats", "ii"],) async def inviteinfo(self, ctx, invite: discord.Invite): embed = discord.Embed(title = f"Server invite: {invite.code}", description = f"Invite created <t:{int(invite.created_at.timestamp())}:R>", colour = ctx.author.colour, url = invite.url) embed.set_author(name = f"ID: {invite.id}", icon_url = invite.guild.icon_url) embed.add_field(name = "Inviter", value = f"{invite.inviter.mention}|{invite.inviter.mention}" if invite.inviter else "Unknown") embed.add_field(name = "Uses", value = f"{invite.uses}/{'Infinite' if invite.max_uses == 0 else invite.max_uses}", inline = True) embed.add_field(name = "Expires", value = f"<t:{int(invite.max_age.timestamp())}:R>", inline = True) embed.add_field(name = "Temporary", value = f"{invite.temporary}", inline = True) embed.add_field(name = "Revoked", value = f"{invite.revoked}", inline = True) embed.add_field(name = "Channel", value = f"{invite.channel.mention}", inline = True) await ctx.reply(embed = embed)
so rn my role giver is going by id how do i make it check the id of the role if the user picked a name of one of the roles that has its id in the list
@bot.command()
async def embed_color(ctx, word):
if len(word) != 8:
await ctx.send('Must be sent in hex code with 0x at the beginning, ex:\n0x5866ef')
else:
bot.e_color = (word).value
embed = discord.Embed(title=f"New color", color=bot.e_color)
await ctx.send(embed=embed)
how do i get the value of word
i tryed (word).value
and it didnt work
here's the traceback
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'value'
thanks in advanced
You don't need to get it
word is what ever the user inputted
Just like defining a variable
word = "abcdefg"
thx
What is up with your indentation
Its not like that on my code lmao dw
its just hte discord removed all the indent
so i had to do a bunch of spaces
lmao the indent on my code itself is fine i just get that one error
lemme see if i can make it abit neater lmao
Fixed lmao
idk why it keeps saying the variable is referenced before assignment 
i do actually
If chosen_Reward is not equal to coins silver or gem it throws that
Okay?
without the ""
It should still send the actual text
so i need the value of the string, or else it doesnt work
i need
color=0x00000
not color = "0x00000"
Then type hint it as an int
OH OH OH
can i join it with 0x at the begining
how can i join 0x with the int
cant be '0x'
well i could do color = {
'0x':0x
}
i guess
what are you planninng on doing?
hexing the color?
if you want to hex the color, you could just hex(color)
!d hex
hex(x)```
Convert an integer number to a lowercase hexadecimal string prefixed with β0xβ. If *x* is not a Python [`int`](https://docs.python.org/3/library/functions.html#int "int") object, it has to define an `__index__()` method that returns an integer. Some examples:
```py
>>> hex(255)
'0xff'
>>> hex(-42)
'-0x2a'
``` If you want to convert an integer number to an uppercase or lower hexadecimal string with prefix or not, you can use either of the following ways...
oh
kk i just saw that
You cannot concatenate an integer
wtf is concatenate
!e
print("a" + "b")
@final iron :white_check_mark: Your eval job has completed with return code 0.
ab
Boom, concatenation
You could try
maybe there's a typehint for hex types?
Then again I don't know if there's a hex type
!e ```py
print("a" "b")
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
ab
Is there a way to get all the badges a user has?
Like
for badge in user:
print(badge)```
just tell me how to put 0x with the int
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
hash(x) Returns the memberβs hash.
str(x) Returns the memberβs name with the discriminator.
no you need to use public_flags
user.public_Flags or member.public_Flags both work
!d discord.Member.public_flags
property public_flags```
Equivalent to [`User.public_flags`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.public_flags "discord.User.public_flags")
Well if the user sends a valid hex why not hex it?
!d hex
hex(x)```
Convert an integer number to a lowercase hexadecimal string prefixed with β0xβ. If *x* is not a Python [`int`](https://docs.python.org/3/library/functions.html#int "int") object, it has to define an `__index__()` method that returns an integer. Some examples:
```py
>>> hex(255)
'0xff'
>>> hex(-42)
'-0x2a'
``` If you want to convert an integer number to an uppercase or lower hexadecimal string with prefix or not, you can use either of the following ways...
wait you could type hint a int, then hex it
for some reason it is doing the code twice
Can we see the code?
maybe u ran it twice
either you have something that runs it twice, or you are accidently running two bot instances
nop not running anything
looks like there might be 2 instances running
Check task manager
wait a minute i just turned off the script and it is still working ...
wdym
Reset your token
you're accidentally running the bot from 2 different connections i guess you could say
hexs arent just numbers
Easiest way to fix it
you need to make sure the word is well an int
its not tho
you can probaly just check the type
theres letters
so what do i do to stpo it
cant be a str
typehinting is your friend
word will always be a string, and if nothing, then error in this case
obv
but you can typehint it to be an int
notice how this will not work?
yes
ty that fixed it
if it's a string it will not work
alr
can u tel me how
?rtfm typehint
?rtfd typehint
?rtd typehint
Hi back 
i lost 2fa codes for my old account :(
async def example_command(self, ctx, word : typing.Union[int, str]):
if isinstance(str):
return await ctx.send('sorry this will not work')
Uh, okay this example is kind of bad, hold on
like another file for a code
as a bot.command π
no, a class is something like
class Test(commands.Cog):
def __init__(self, bot):
self.bot = bot
this is like a cog class, well subclass
import typing, then you are good
a union is is something or something
hexs arent just intergers
so Union[X, Y] is the same as X | Y
and strings dont work
I wonder
Yes but you need python 3.10+
if it doesn't you may need to make a regex converter of your own
mhmm
why
!e
print(int("0xE91E63"))
@final iron :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | ValueError: invalid literal for int() with base 10: '0xE91E63'
!e
print(int("0xE91E63", 16))
@sick birch :white_check_mark: Your eval job has completed with return code 0.
15277667
mm
hexes are technically another representation of integers are they not?
But its not a discord hex code
You could probaly run regex on the hex
with like a discord.py commands converter
Then convert it back to int
Doesn't discord use a "flavour" of hex or smth?
Can't the discord.Color be used as a typehint?
perhaps try RGB, might be easier since discord.Colour has a .from_rgb() @classmethod
I've seen it somewhere
Lol
^
No
to make it a rgb
you can just typehint to discord.Colour and forget all of that
do you know what type hinting is?
word: Union[int, str]
Union is the type hint for the word param
@bot.command()
async def myColorEmbedCommand(..., colour: discord.Colour, ...):
await ctx.send(embed=discord.Embed(..., colour=colour, ...)
that's all you have to do
kk
idk if you can change color of fieldsm, titles, etc if that is what you want
no
You can only change the color of the left bar on embeds
yes now colour will be what you pass in to the embed's color kwarg
and you can get rid of that if/else by the way, d.py will handle that for you
you didn't specify color arg when invoking the command prob
wdym
the first arg is word, 2nd is colour
your command atm when invoking is !cmdname <word> <colour>
ok
you prolly didn't specify something for colour
you need to call it like this:
<prefix>embed_color <word> <hex>
^
yes
is it hex
good
why
or like red
not moai π
@client.event
async def on_member_update(before, after):
if ".gg/" in str(after.activity.name):
guild = client.get_guild(932840827212931123)
role = discord.utils.find(lambda r: r.name == 'promoter', guild.roles)
await after.add_roles(role)```
gives role but doesnt take it
what am i doing wrong?
πΏ
take what?
:moai: vs πΏ
doesnt take role whenever user removes status
because there's no code that takes away the role?
^
if the vanity is not in after status name anymore, remove the role
idk code for that
!d discord.Member.remove_roles
await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the removed [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
yes ik that
but the other part, like i cant just put blank in the "" because they might change it to something else directly after taking .gg/ out
what happens you do this?
like this?
yes
jack shit
!d startswith
startswith
Case-sensitive starts-with.
Example:
Entry.objects.filter(headline__startswith='Lennon')
``` SQL equivalent:
```py
SELECT ... WHERE headline LIKE 'Lennon%';
```...
!d str.startswith
str.startswith(prefix[, start[, end]])```
Return `True` if string starts with the *prefix*, otherwise return `False`. *prefix* can also be a tuple of prefixes to look for. With optional *start*, test string beginning at that position. With optional *end*, stop comparing string at that position.
doesnt change the color
if "vanity" not in str(after.status.name):
# take away role
maybe?
because you're setting the embed color to bot.e_color rather than colour
i want it to be bot.e_color bc i want it to change the color of al the embeds
then set bot.e_color to colour
for reference
Sorry @pallid mango, caught by the spam filter. Remove the server invite link in order to post the code.
exactly like so, what's the red squiggly telling you though?
why reference that
@client.event
async def on_member_update(before, after):
if "" in str(after.activity.name):
guild = client.get_guild(932840827212931123)
role = discord.utils.find(lambda r: r.name == 'promoter', guild.roles)
await after.add_roles(role)
if "" not in str(after.status.name):
await after.remove_roles(role)```
there you are
oh wait, my bad i forgot to remove the second vanity in the not in code
Also role is restricted to the scope for the first if
Guys does anyone have ticket system source?
move it outside both ifs so it's restricted to the on_member_update scope
anyone know how to fetch lyrics from youtube-dl?
okay
youtube-dl is against our TOS as it can be used to write music bots, or help in creating music bots, so we can't help with that unfortunately
No, but we can help you with certain problems you may encounter when writing one yourself
ok, it doesn't download youtub vids tho
Regardless we can't provide assistance with that library
@client.event
async def on_member_update(before, after):
if ".gg" in str(after.activity.name):
guild = client.get_guild(932840827212931123)
await after.add_roles(role)
if ".gg" not in str(after.status.name):
await after.remove_roles(role)
role = discord.utils.find(lambda r: r.name == 'promoter', guild.roles)```
ok,
Now it won't be able to find it since it's declared after everything else, you have the right scope but declared at the wrong place



