#discord-bots
1 messages ยท Page 684 of 1
yea I just had my breakfast
that's how you get the author's ID yes
:incoming_envelope: :ok_hand: applied mute to @small igloo until <t:1639621077:f> (9 minutes and 58 seconds) (reason: mentions rule: sent 6 mentions in 10s).
..
๐
Rip
they should be unmuted already
i send 4 pings, not 6 bruh
also i have idea, how to make this
<t:UNIX:formatter>
uh?
the numbers are unix/epoch time whatever you wanna call them
https://discord.com/developers/docs/reference#message-formatting-formats
https://www.epochconverter.com/
<t:1623981015>
oh nice it works
<t:1623981015>
hm ok ok, thanks
I keep getting this and I can't fix it.
aww, ilysm
What's the code look like?
A tiny snippet of the error doesn't help us understand what the error is trying to say
name ctx anything you can
:3
Now this happens.
message.channel.send
lol where channel
me on 20 minutes
Relatable.
what, u need channel, u can't leave message and send without channel, they need channel to live, without channel they can't live
2 months ago i'm not sleep strike 3 days
Lol.
not even kidding lol
You talking about the commands extension or like actual commands? 
Ive done that my test sucked.
"lol"
what test is it
umm....
Trigonometry, was*
!ot
Off-topic channels
There are three off-topic channels:
โข #ot2-never-nesterโs-nightmare
โข #ot1-perplexing-regexing
โข #ot0-psvmโs-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
bhre ok
Do I need await?
yes
for send message? bhru that's the most importatnt part
Sorry, I'm more of an ethical hacker of wifi.
lol wifi stealer
No, I only do it to my family to scare them that I know the password.
what? ur family not let u know the pasword? oof
Its not iilegal I'm a white hat.
If its one that I've never been to, like if they moved.
what
lets keep the discussion to #discord-bots
I know, but I have ADHD I get off topic easily.
#networks for you
Thats networking?
hope u can get well soon
How can i make a channel private for everyone. Obviously not for people with administration permissions.
I've had it since birth, but I can control it Juice WRLDS music helped.
WRLDS
It's not hacking.
hacking requires you to learn networking first so uhh
mistakes happen, i'm sorry
?
Well, I don't do it unless needed.
no, hacking requires you to learn hacking
idk
lol ok
hackin5n3 smth
ethical hacking can actually be a great way to learn new concepts and strengthen existing ones
anyways, keep it #discord-bots
k
what
you can do this by
Making a permission overwrite for the guilds default role
hmm, ok i almost forgor to ask again, why the coin is empty
But i want to make it available for the person that invoked the command
await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sets the channel specific permission overwrites for a target in the channel.
The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that belongs to guild.
The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.
If the `overwrite` parameter is `None`, then the permission overwrites are deleted.
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...
coin?
!d discord.Message.edit
await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., 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.
#bot-commands
what does await client.process_commands do?
!d discord.ext.commands.Bot.process_commands @mild birch
await process_commands(message)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This function processes the commands that have been registered to the bot and other groups. Without this coroutine, none of the commands will be triggered.
By default, this coroutine is called inside the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event, then you should invoke this coroutine as well.
This is built using other low level tools, and is equivalent to a call to [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") followed by a call to [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
This also checks if the messageโs author is a bot and doesnโt call [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
Hey
has nothing to do with anything
!d discord.Guild.get_member
discord commands out of context of the conversation belong to #bot-commands
haii
from flask import Flask
from threading import Thread
app = Flask(__name__)
@app.route('/')
def main():
return {"hello": "everything is ok"}
def run():
app.run(host="0.0.0.0",port=8080)
def a():
server = Thread(target=run)
server.start()โ
Showing invalid identifier error?
doesn't relate to #discord-bots
replit?
Ys
yeah 
go to #web-development
No
yes
It is for discord bot hosting
Doesn't mean anything.
mhm
Idk. If you can give me a code for hosting that would be nice
that's probably the error
If the bot gets a user and it returns this, is it still a discord.User object or no? or is it just a string
in main() return a string and it should work
For example
def main():
return "smh"```
Can I be your friend
I don't allow friend reqs so...sure
Thats a question ive never heard
from flask import Flask
from threading import Thread
app = Flask(__name__)
@app.route('/')
def main():
return "hello"
def run():
app.run(host="0.0.0.0",port=8080)
def a():
server = Thread(target=run)
server.start()โ
It still shows same error
Very random and funny question if i say so myself
Uh you can also be my friend
I've seen that quite a lot of times lol
So I have a queue command for players to q up for a game
# !q command -> Puts players into queue
@bot.command(name="queue", aliases=["q"], description="Join the queue")
@commands.check(is_issuer_in_game)
@commands.has_any_role(verified_role, 908784013181878342)
async def queue(ctx):
try:
if ctx.channel.id in allowed_channels:
...
------> qtimer_tasks[game_id].append(asyncio.create_task(qtimer(timedplayer, game_id, qsize, channel)))
print(qtimer_tasks)```
qtimer function is a timer until the player gets disconnected from the queue:
```py
async def qtimer(timedplayer, gameid, qsizee, channel):
try:
await asyncio.sleep(15)
if gameid not in games:
playerqueue.remove(timedplayer.mention)
lobby.remove(timedplayer.id)
if len(playerqueue) > 0:
embed = discord.Embed(
title=f"**{len(playerqueue)} of {qsizee} players are in the queue**",
description=str(timedplayer.mention) + " was kicked from the queue! (Timeout)",
color=0xE74C3C)
else:
embed = discord.Embed(
title="**There are no players remaining in the queue**",
description=str(timedplayer.mention) + " was kicked from the queue! (Timeout)",
color=0xE74C3C)
embed.set_footer(text=f"CBell 6 Mans | Created by Heptix",
icon_url="https://i.imgur.com/1utxX7d.png")
await channel.send(embed=embed)
except Exception:
print(traceback.format_exc())```
however, the task isnt completing as I am not getting kicked from the queue after 15 seconds?
Im not getting any errors either, only console line telling me
> ```defaultdict(<class 'list'>, {99: [<Task pending name='Task-51' coro=<Command.__call__() running at C:\Users\~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py:358>>]})```
umm....
Alone wolf lol
!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.
Maybe because your a female
Or sm
stress
School you ment?
?
Uh no.
Lol
Because they helped me
kind of, but nvm
huhhh
Thats nice
Girls dont help loool
I think you did ment it
Still doesn't work though
Why?
from flask import Flask
from threading import Thread
app = Flask(__name__)
@app.route('/')
def main():
return "hello"
def run():
app.run(host="0.0.0.0",port=8080)
def a():
server = Thread(target=run)
server.start()โ
It still shows same error
thinker said that not me
Im not thinker lol
Lol
are you calling the a function in your main file?
Im a different human bean
Yes
import a
a.a()
that's some weird naming
Delete the character lol
umm....try backspacing
Which one
Your iq is super high
after start() there's an invis character
its over 9000
Replit is literally showing you lol
Nah higher
So I have to remove ()
server.start?
that was an anime reference but nvm
noooo
just write that line again
to make things simple
Wdym
@fluid harbor
something.something()#
``` theirs a invalid character
I'm sorry if this is the wrong channel (I don't know where else to post.)
I want to develop a bot for my discord server. Is there an easy way that does not involve complex coding?
My knowledge of Python is less. Can anyone help me?
I will be awaiting replies.
.no
what kind of bot?
I didnt understand
from flask import Flask
from threading import Thread
app = Flask(__name__)
@app.route('/')
def main():
return "hello"
def run():
app.run(host="0.0.0.0",port=8080)
def a():
server = Thread(target=run)
server.start()โ
So what to remove or add?
Its an example where theirs an invalid character
I want it to moderate my server.
use a preset app that's all I can say
You can use official bots ig
the commands r a bit confusing for me
I mean theres no way to make a moderation bot without 'complex coding' if you wanna make a good 'moderation' bot
I think me bot can make bots idk
Uh
Use the help command lol
???
you can use help commands they provide
ik python till if-else conditions only
from flask import Flask
from threading import Thread
app = Flask(__name__)
@app.route('/')
def main():
return "hello"
def run():
app.run(host="0.0.0.0",port=8080)
def a():
server = Thread(target=run)
server.start()โ
What to add or remove.........
.....
............
!resources then
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
k
try this ```py
from flask import Flask
from threading import Thread
app = Flask(name)
@app.route('/')
def main():
return "hello"
def run():
app.run(host="0.0.0.0", port=8080)
def a():
server = Thread(target=run)
server.start()
hey
Both are same. What's the difference
python gotta adjust
yes?
an invisible character that you cant see that I maybe deleted
Delete this space after start()
Hm
What?
nothing, imma keep quiet
Type hinting the bot is necessary
Still doesn't work@boreal ravine
@upbeat otter what type hint are you talking about?
Because in __init__() it is required
bot: commands.Bot
Eveee whats your birthday year?
Theirs 2
doesnt matter
||Lol||
wdym
How is that related to the topic if the channel
Sorry
Look at the setup function
and?
Were you talking about that type hint?
def setup(bot):
bot.add_cog(whatever_class(bot))
I was saying that typehinting bot wasnt necessary
Yes you are correct lol
smh
hmmm yeah
Any question?
About it?
We would gladly help you understand
You dont load extension is to load cogs
Mhmm
i literally cant understand your messages....
Me either
# in cog file
def setup(bot):
bot.add_cog(Cog(...))
# in main bot file
bot.load_extension("cog.name")
arguing for what
Dont quite understand anybody here
wao....
they did that already
Then what's the error
we were waiting for you, Lord
cog has no setup function even though it has one
I was sleeping, so uhh
Okay... Show a screenshot of the setup function
im not the person who got the error
Oops wrong reply
its 9
are you sure your running the right file? maybe you have another bot with the same file and your pc is running that one
I slept at 1:30 so uhhh
timezones
same timezones
@hidden hazel show a pic of the file
you sleep? :D
Bro no, the cog file
Idk
Probably not
Yea
Uhhh, can u show the main bot file where u r loading the Cogs?
That should have worked
So commands cog gets loaded, right?
๐ณ ๐ถ
why flushed xD
So that tells there's a problem in your listeners file, not in the main bot file
Did u try restarting the bot?

@hidden hazel
@hidden hazel are you running the latest file of your bot
because its outside your class
It should be outside
yep
why imagine, make it
!d discord.ext.commands.Bot.load_extension ..?
load_extension(name, *, package=None)```
Loads an extension.
An extension is a python module that contains commands, cogs, or listeners.
An extension must have a global function, `setup` defined as the entry point on what to do when the extension is loaded. This entry point must have a single argument, the `bot`.
Like in the dpy source code, it's already written
class Cog(...):
@classmethod
def setup(cls, bot):
bot.add_cog(cls(...))
And the library just does Cog.setup(self)
@maiden fable whats the package kwarg for?
Never tried it tbh
hm
No external setup method needed
Idts
use try and except when you load the extensions
But it goes get loaded
That's just gonna eat errors, also no need since we already know the error
mhm, of course
you just woke up that's obvious
Delete the type hint cause why not
No need for it either
I'm too sleep-deprived, cant help with typos, im sorry
Well ๐คทโโ๏ธ
๐ถ
Lmao
Bruhhhhh ๐
๐คฃ
me too, bye
Lmfaooo
wrong gif nvm
Get some sleep y'all, imma play some games help everyone here
Insomnia and I have an exam in 2 hours
go play
best of luck
Thanks
I have anxiety ๐ถ
My grades are coming soon and if i fail again no pc and programming for me for 5months๐ถ
๐
Wdym
Your token just resets for no reason
When discord spares me
I just saw your full about me now but nvm
You still need to close the dict lol
thats the inspect element but nvm
I still cant see it๐ถ
me too
Now i will cry myself to sleep๐ถ
bye
Bye๐ถ
Its None lol
Thats like saying
str("")
๐ถ
Maybe it got reset ๐ถ
๐ด๏ธ
how do i make a guild mark as read in my bot
You were going to cry 5 minutes earlier
Better example
a =
print(str(a))
I did
Yes but tokens arent ints their complex so bad example
REALLY ๐ฑ
Just type random stuff lol
Random stuff and not random ints
:levitate:
OMG REALLY ๐ฑ
Im joking i know lol
Just an example if you try to convert or edit something that's none
Sure
Replits envs dont work like that
Me who uses a python file to save the token ๐
๐ถ
I dont use replit so idrc
U can use os.getenv on repl too tho
I just do in my files:
import stuff
vars = stuff
TOKEN = "hiimacooltokenlol"
#code
bot.run(TOKEN)
Looks good in my opinion
Bro holy shit
light mode gives me aids omg im not even kidding
my eyessssssssssssssssssss holy shit
Make it full brightness
your problem?
hm , make sure you use the same variable name and capitalisation when you do it
what ide/editor are you using?
oh , do you use the play like button on the right top to run your code?
dont do that , use this instead
run without debugging option
may i see your .env file , with the token removed ofc
im guessing it's just TOKEN=''
it should be TOKEN =
since you use getenv('TOKEN')
yea just rename it , and use the run option i told , should work foinu
and where did you run it from?\
nah i mean , the play button
or the debugger option i told
await bot.get_channel().send(.... is what i do
that's reasonable
lemme try doing it myself , brb
ok so i have this in my bot file py Kakashi.run(getenv('TOKEN'))
this is my .env file
TOKEN ='token here'```and it works like a charm
Yes ofc
get() is async but fetch isnt
what did you name your env file? .env ill suppose , right?
( opposite )
Huh?
fetch is a coro and is async
get is a normal def
Read it again
get() is async but fetch isnt
READ IT AGAIN
dawg bot.get_channel and get() are the same jk
actually idk, i have never used get() before
Same
If you get really simple, yea get and get_channel are basically the same
What was that๐ณ
Or they do the same thing/can do the same thing
๐ once a guy told me "hey why u use indexing it trash"
because i did
!e
import random
element = [1, 2, 3]
print(f"{element[random.randint(0, 2)]}")
@shadow wraith :white_check_mark: Your eval job has completed with return code 0.
1
and he kept telling me to use random.choice ๐, if it does the same thing it does the same thing, andy told smth important
Well, yea the eval code you sent makes no sense for you to index here
Indexing is fine, but you don't need to use it when you don't need to
Its a bit implicit imo
But i havent added a cog yet so
!e
x = ['one', 'two', 'three']
print(x[0])
@spring flax :white_check_mark: Your eval job has completed with return code 0.
one
Ah picking๐ด๏ธ
Remember now lol
picking?
I just like calling it that๐ด๏ธ
transcript_file = nextcord.File(io.BytesIO(transcript.encode()),
filename=f"transcript-{ctx.channel.name}.html")
await ctx.send(file=transcript_file)
```i want this it show like this in embed hyper link format how to do so?
its a file so if i do text it doesnt work
As far as I know [text](url) are only for hyperlinks.
but i cnt do it cuz its a file
Show code?
yeah, because discord doesn't support that
maybe you could use the pastbin api and upload your file there and send the link of the uploaded file
its an html file
it is a kind of ss
ig it can be done like only if i have a website of my own which is hosted
I've been trying to make a useful discord bot for a while, but I can't get a good idea of what people would want to use, does anyone here have any ideas on a useful discord bot I could make?
yeah, you could make your own website for that using django or flask
I had a question
over here as u can see we are tabulating text
similarly is there a way to tabulate images?
like the avatar
Like command ideas?
or a bot concept idea, every idea i've thought has been done by almost every other discord bot (i haven't had many good ideas)
I don't really have concept ideas
a truly fully customizable all-purpose bot
all the bots available rn aren't FULLY customizable
what do you mean by fully? (to what extent? you can change any messages send, you can change any logic, or you can change the code?)
the first and second
You would need to use PIL for that
Pillow
yea but before that I have to make table of avatars
so I can use it to draw on img
You need pil to draw lmao
If I have a function that I want to call using 2 different aliases but when a certain alias is called it does a different task how would I do that? @client.command(name="call1", aliases=['call2']) async def call1(ctx): if(call1): do this if(call2): do this instead Something like this
Well just create an another command instead
Yeah I could do that but they are esentially the same thing but changing one variable inside
I feel like the wouldent be very efficient
Basically I wanna change a value baised on what the input it
The thing is, aliases will call function which you have made an alias too
You could just take an argument instead
Use tabulate to generate tables and use PIL to draw it
I was using tabulate module for text
tabulate doesnt work for avatars?
Tabulate only generates text
yea thats why
How will it work on an image
bro thats why I asked the question
You need PIL to draw the image
here
Use tabulate to generate the text
and use pil to take that text and draw on it on the avatar
to "generate text"
Use both
you have to use PIL in order to write or read text from images and based on that you can use tabulate to do stuff and then use PIL again to work on the image
dont create a new command
Oh wait, what are you exactly try to do
!d discord.ext.commands.Context.invoked_with || this shows the alias it was invoked with, you can just do if ctx.invoked_with == โฆ
The command name that triggered this invocation. Useful for finding out which alias called the command.
What are you trying to do?
not necessary
i gave the most efficient way
how so?
What're those?
I mean I dont wanna discuss it further cuz its really not helping me .. not ur fault tho.. I was just trying to create leadberboard using tabulate text etc which all worked but now I want to tabulate avatars as well the same way I am doing for text in my leaderboard
I will try to figure it out ๐
Flags are like CLI, like you have a command line
some_command -sub_command something
That's what I said
How are you generating the data
Oh command line flags
how would that be โbetterโ than a one line check?
from my postgres sql db
u mean the user ids or
the avatar
btw I am generating avatar by fetching user object from user id
and I take the user id from my db
I mean, they can take arguments with too, and the flag itself can have aliases
So yeah it would be better imo
But your way works too
they asked for aliases, not arguments
So you can get the user data, create a table as a text and pass it to PIL and use PIL to write the text on the image
I know that, it was just a suggestion
it already worked
but avatars cant be created as table of text
Imma just share the github code one sec
Alright
not a very needed one
so this is the general code I am talking about .. now as u can see here u open a template and then add tabulated text on the image by drawing
Okay lol, I can give suggestions about something that I know, don't be such an ass about it
all of that I was able to do but what if I want to create another table of user avatars near the names of users
to make my leaderboard better
im not being an ass, someone asks how to make a kick command and you tell them how to make a mute command - not very useful is it?
Dont fight please ,-,
I gave a suggestion that can be useful for them, about command flags, yes they didn't ask for it exactly, but what's the harm in knowing about it. Stop making bullshit comparison.
Yeah, sorry
Good
Oh now I get it, so like let's say you have 3 rows
And you want something like this
- Avatar: data
- Avatar: data
- Avatar: data
Like that?
yea basically one column of avatars with multiple rows
brb
Okay
wait I have an example
class FullMenu(disnake.ui.View):
message: disnake.Message
def __init__(self, embeds: list[disnake.Embed]):
super().__init__(timeout=90.0)
self.embeds = embeds
self.embed_count = 0
async def on_timeout(self):
await self.message.edit(view=None)
@disnake.ui.button(label="", emoji=":rewind:", style=disnake.ButtonStyle.blurple)
async def first_page(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if self.embed_count == 0:
pass
else:
self.embed_count == 0
embed = self.embeds[self.embed_count]
embed.set_footer(text=f"Page 1 of {len(self.embeds)}")
await interaction.response.edit_message(embed=embed)
@disnake.ui.button(label="", emoji=":arrow_backward:", style=disnake.ButtonStyle.blurple)
async def back_a_page(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if self.embed_count == 0:
pass
else:
self.embed_count -= 1
embed = self.embeds[self.embed_count]
embed.set_footer(text=f"Page {self.embed_count + 1} of {len(self.embeds)}")
await interaction.response.edit_message(embed=embed)
@disnake.ui.button(label="", emoji=":arrow_forward:", style=disnake.ButtonStyle.blurple)
async def next_page(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if self.embed_count == (len(self.embeds) - 1):
pass
else:
self.embed_count += 1
embed = self.embeds[self.embed_count]
embed.set_footer(text=f"Page {self.embed_count + 1} of {len(self.embeds)}")
await interaction.response.edit_message(embed=embed)
@disnake.ui.button(label="", emoji=":fast_forward:", style=disnake.ButtonStyle.blurple)
async def last_page(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if self.embed_count == (len(self.embeds) - 1):
pass
else:
self.embed_count == (len(self.embeds) - 1)
embed = self.embeds[self.embed_count]
embed.set_footer(text=f"Page {len(self.embeds)} of {len(self.embeds)}")
await interaction.response.edit_message(embed=embed)
That's an image right
Hey @untold token!
It looks like you tried to attach file type(s) that we do not allow (). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.
Feel free to ask in #community-meta if you think this is a mistake.
yea
Oops
yes everything is there in my leaderboard except the avatars
Try to debug it and look what happen
nothing happens lol
the first / last page buttons just go to the last page
Well when you generate the lb, maybe you can add some kind ID system that like
- ID: data
And when you are generating the image, compare the ID and paste the image with right size and send it
but dont set the embed count
You can use user IDs ofc
self.embed_count == 0
in first page, it is an assignment, why double equals? you are setting self.embed_count equals to True
or false lol
yea but how do I make a table of those avatars
thats the main problem
yeah that fixed it ty
Oh wait I maybe a have a better idea, first use the lb to sort out let's say, top 10 users, create a dummy table or something and add the avatar in the lb format,then when that image is generated, write your data on the image in those boxes
@untold token can u help me
To generate images , you need to loop
np. If i can suggest another thing, in your code you are checking for example if the page is equal to 0 or equal to the length but usually, for convenience, it is better to check if the variable is not equals to something, so you don't need the pass statement, for example:
if self.embed_count != 0:
#do your stuff
if self.embed_count != (len(self.embeds) -1):
#your other stuff
nothing change of course, but the code will look a little bit better
you will not even need to use the else statement doing it like this
yeah ty, less code always better, just changed it
why have the label kwarg if your not even gonna use it lol
which kwarg
i said it in my message ๐ค
I dont see a label kwarg?
wtf
can you see it now
oh
I was testing stuff with it idk
didnt wanna retype the label each time
everytime I respond back with the response type 7 in my discord components using my bot keeps returning that this interaction took too long to respond or you have already responded to it, but when I switch the token to a different bot using the exact same bot everything works fine
(I am using a third party package for the discord packages -- discord-components)
` if message.content.lower() == '>register':
with open("/Users/bai/Documents/Personal Things/PythonDiscord/userprofile.txt",'a') as f:
f.write(str(message.author.id) + '\n')
f.write("UserBal: 0" + '\n')
if message.content.lower() == '>bal':
with open("/Users/bai/Documents/Personal Things/PythonDiscord/userprofile.txt",'r') as f:
print(f.readlines())
if str(message.author.id) in f.read():
print('true') `
im trying to let python read the text file
First is the user id
and then the user bal
all the other parts work, except for the last 2 lines
Anyone here decent with asyncio.tasks 
Been making help channel after help channel but no one has responded. I feel I have given all the necessary information
i think you need to defer it but deferring an interaction is only in dpy forks/dpy 2.0
Don't use quotations in .env file..
Use,
TOKEN= UHD21BXJSK6_31BDDNMZNS```
Like that...
= a whole datacentre
It's not any valid token value I just showed an example.
they probably meant mbs
In env file the key must be uppercase, such as
TOKEN, not Token
what would happen if I have quotes, I have always used "" for token in .env
Not recommended
but in theory it should not affect my code at all
Have you stolen a NASA a PC? ๐
bro owns a whole datacentre in 1 pc
WTF
I want it too hahaha
4096 GB
Anyone know why discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: ffmpeg was not found. is popping up?
Im trying to get my bot to play an mp3
music bot..?
ffmpeg was not found
No just an mp3 file
Simply says that
check the file directory
you don't have ffmpeg installed?
Install ffmpeg
@astral cobalt
Ohhhh I though it was saying it couldent actually find the file
Okay sweet thank you
@tiny ibex Still says discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: ffmpeg was not found. even though I imported it
U gotta install it from the official website
I cant just use pip?
once my bot reatarts...if i used buttons in my bot...why does it show interaction failed? how can i solve that?
i need to set the button roles again so that it works
anyway to solve that?
@astral cobalt
same thing for mac?
but the mac version instead of windows
do I just clone the git to the folder my bot is in?
anyone know how I can update the options in a dropdown menu when a command is used, and how I can change the view to the updated options view
await msg.edit(view=NewView())
I do that in the dropdown class?
View class
Where u wanna edit the message with a new view
Use ffmpeg with Python binding, there is a library you can use.
!pypi ffmpeg-python
!pypi ffmpeg-python
Hmm but I recommend raw FFmpeg
Just my wish
ยฏ_(ใ)_/ยฏ
(Discord.py) My mind is melting while trying to understand Cooldown and CooldownMapping ๐คฆ
I wanted to detect spam messages that is sent to every channel...
And CooldownMapping isn't documented, how can i learn about these or could someone explain me?
!custom-cooldown
Cooldowns in discord.py
Cooldowns can be used in discord.py to rate-limit. In this example, we're using it in an on_message.
from discord.ext import commands
message_cooldown = commands.CooldownMapping.from_cooldown(1.0, 60.0, commands.BucketType.user)
@bot.event
async def on_message(message):
bucket = message_cooldown.get_bucket(message)
retry_after = bucket.update_rate_limit()
if retry_after:
await message.channel.send(f"Slow down! Try again in {retry_after} seconds.")
else:
await message.channel.send("Not ratelimited!")
from_cooldown takes the amount of update_rate_limit()s needed to trigger the cooldown, the time in which the cooldown is triggered, and a BucketType.
this may be helpful
So, what CooldownMapping and get_bucket does? And what is a bucket
Sorry if i am being dumb, my mind is melting right now :(.
@dapper cobalt, please enable your DMs to receive the bookmark.
.bm
class Close(nextcord.ui.View):
def __init__(self):
super().__init__()
self.value = None
@nextcord.ui.button(label = "Close", style=nextcord.ButtonStyle.red)
async def tClose(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if interaction.user.guild_permissions.manage_messages:
await interaction.channel.delete()
elif interaction.user.guild_permissions.manage_messages is not True:
await interaction.channel.set_permissions(interaction.user, view_channel=False)
self.value=True
class Tickett(nextcord.ui.View):
def __init__(self):
super().__init__()
self.value = None
@nextcord.ui.button(label = "Paid Ticket", style=nextcord.ButtonStyle.gray)
async def inv(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
categ = nextcord.utils.get(interaction.guild.categories, id=918104010135834674)
await interaction.response.send_message("Creating a ticket for you, this may take a while!", ephemeral=True)
ticket_channel = await categ.create_text_channel(name=f"{button.label}{interaction.user.name}")
embed=nextcord.Embed(description=f"<#{ticket_channel.id}> - Your ticket has been created")
await interaction.edit_original_message(embed=embed)
await ticket_channel.set_permissions(interaction.user, read_messages=True, send_messages=True)
view=Close()
await ticket_channel.send(f"{interaction.user.mention}")
embed = nextcord.Embed(title=f"Support Needed!", description=f"A ticket opened by **{interaction.user.name}**,\n Server Display name is **{interaction.user.display_name}**\n Support will be with you soon!\, Please describe your problem in the chat!\n The **Close button** can only be used by staffs with manage messages perms!", color=0xFF0000 )
await ticket_channel.send(embed=embed, view=view)
self.value=True```
i have this ticket sys right here...i want that in the class of "Tickett" the interaction.user...who opened the channel...his perms of view_channel shud be false whenever someone clicks the close button
how to do it?
sup
how can i get a list of all the command author's roles?
how can i only get channels that my bot can see, because for channel in ctx.guild.channels shows every channel in the server
!d discord.Member.roles
property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [โ@everyone](mailto:'%40everyone)โ role.
These roles are sorted by their position in the role hierarchy.
all the details aka role object
class discord.Role```
Represents a Discord role in a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild")...
how can i make it return only name tho
The name of the role.
for role in ctx.author.roles:
print(role.name)
await ctx.send(', '.join([role.name for role in ctx.author.roles]))
ty, what if i want to make it into a list var instead of sending it..?
do i do this outside of the loop?
yeah i think so
?
yeah you can use list comprehensions
outside of wut loop?
the for loop
for
the for loop is in one line
anyone?
no, you either choose the list comprehension or use the for loop, both is the same
how can i only get channels that my bot can see, because for channel in ctx.guild.channels shows every channel in the server
no?
listVariable = [role.name for role in ctx.author.roles]
'''
or
'''
for role in ctx.author.roles: i = role.name #do other stuff
same thing
are you sure?
are you sure it doesnt have admin or anything
i was helping the other guy
yep
it doesn't have admin
I was just stating that both are the same ,-,
no idea but you could loop through the the guilds channels permissions and see if the bot has the view_channel permission and if it does, append it to a list or something
thx
how can i check for permissions with a channel object
^^ you can iterate through that and check if your bot has a certain permission
isinstance(channel, CategoryChannel)
roles = [role.name for role in ctx.author.roles]
print(roles)
rolename = await client.wait_for('message', check = check, timeout = 20)
if rolename in roles:
await ctx.send(embed=discord.Embed(description="Ok!!"))
else:
await ctx.send(embed=discord.Embed(description="You don't have that role!"))
sends "you dont have that role" even though i do. i printed the list roles out and the role i wrote was there? whats the problem?
Try printing rolename
?
is the content with a ()?
no
No it's a property
imagine danny made that a method
k
thx it works
now how do i get a role from its role name alone?
is there any other way than using utils?
i dont think so
ok how do i use it with utils
you would have to loop thru guild.roles , but utils.get does the same already
!d discord.utils.get
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
so basically utils.get(guild.roles , name='role name')
No
therole = utils.get(ctx.guild.roles , name='role name') like this?
@maiden fable@slate swan??
sure
it says utils is undefined
discord.utils
from discord import utils?
Yea
is there a way to tell with pillow where the text is ending? like over here how to tell pillow that I want to put discriminator after the username
I know I could just join the two strings
but then I also want different fonts for them
code:```py
therole = utils.get(ctx.guild.roles , name=rolename)
print(therole)
```py
None``` why?
wrong role name
roles = [role.name for role in ctx.author.roles]
print(roles)
rolename = await client.wait_for('message', check = check, timeout = 20)
if rolename.content in roles:
await ctx.send(embed=discord.Embed(description="Ok!!"))
therole = utils.get(ctx.guild.roles , name=rolename)
print(therole)
how it is wrong??
do rolename.content in the name kwarg.
Claim a help channel or ask in #python-discussion
I thought help channel is for coding related errors etc?
ohh i always forget
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeโs robots.txt file; (b) with YouTubeโs prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
is discord.py
no, is youtube_dl
This would also be appropriate
is js better than python for good bots ?
ye
Itโs all preference
send takes an file/files kwarg , use it
!d discord.Webhook.send
await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., wait=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message using the webhook.
The content must be a type that can convert to a string through `str(content)`.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object.
If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") and it must be a rich embed type. You cannot mix the `embed` parameter with the `embeds` parameter, which must be a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects to send.
shopp.append({'name', rolename.content, 'price':price.content, 'desc':desc.content})
it underlines this 'price':price.content, 'desc':desc.content}) and says invalid syntax why? ๐ญ
because you put a comma after 'name' not a colon
that makes it a set, not a dict, so when you treat it as a dict later its seen as an error
Good morning guys
Good day
good night
!d print spring dale senior school 10 times
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)```
Print *objects* to the text stream *file*, separated by *sep* and followed by *end*. *sep*, *end*, *file*, and *flush*, if present, must be given as keyword arguments.
All non-keyword arguments are converted to strings like [`str()`](https://docs.python.org/3/library/stdtypes.html#str "str") does and written to the stream, separated by *sep* and followed by *end*. Both *sep* and *end* must be strings; they can also be `None`, which means to use the default values. If no *objects* are given, [`print()`](https://docs.python.org/3/library/functions.html#print "print") will just write *end*.
The *file* argument must be an object with a `write(string)` method; if it is not present or `None`, [`sys.stdout`](https://docs.python.org/3/library/sys.html#sys.stdout "sys.stdout") will be used. Since printed arguments are converted to text strings, [`print()`](https://docs.python.org/3/library/functions.html#print "print") cannot be used with binary mode file objects. For these, use `file.write(...)` instead.
hmm?
oh tysm
can i ask a question?
thats what the channel is meant for
oof
Lol
So i have a thanks counter... all good but when im trying to get the data its just showing []
ur pfp is pog
um I don't understand
Thx lol
it that some database , list , dict or smthing?
also , show related code
Wait
@commands.command()
async def thanks(self, ctx, member: discord.Member):
thanks = await self.db.execute("SELECT * from thxcounter where user_id = ?",(member.id,))
counter = await thanks.fetchall()
print(counter)
em = discord.Embed(
title=f"{member}'s thanks",
description=f"**You have a total of `{counter}` thanks!**")
await ctx.send(embed=em)
have you commit when updating the db?
it means there's no data for the member..... , how do you insert data?
Yea
await self.db.execute("INSERT INTO thxcounter (user_id, thanks) VALUES (?, ?)", (member.id, + 1))
await self.db.commit()
and at what event does it take place? you can have a print statement there to check if its actually getting added
( also ,as per your code the +1 changes the thanks to 1 , not add 1 to it.)
Ik
What i need to print?
https://inloop.github.io/sqlite-viewer/ open the db here and try checking if the member id is in db
sqlite file viewer
you need to fetch with Cursor object
you miss a , in the (member.id, + 1)
add one at the last
await self.db.cursor().fetchall() try that
AttributeError: 'Result' object has no attribute 'fetchall'
they dont, only a one elem tuple needs the last extra comma
oh , i see
^^^^^^
'Result' object?
show updated code
@commands.command()
async def thanks(self, ctx, member: discord.Member):
thanks = await self.db.execute("SELECT * from thxcounter where user_id = ?",(member.id,))
counter = await self.db.cursor().fetchall()
print(counter)
em = discord.Embed(
title=f"{member}'s thanks",
description=f"**You have a total of `{counter}` thanks!**")
await ctx.send(embed=em)
what is self.db? Cursor object? Or Connection?
its aiosqlite
import discord
from discord.ext import commands, tasks
import aiosqlite
class thanks(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.db = None
self.bot.loop.create_task(self.connect_database())
erm.. how should I handle this? ```py
disnake.ext.commands.errors.NoEntryPointError: Extension 'MyBot.cogs.moderation.init' has no 'setup' function
show connect_database() method
async def connect_database(self):
self.db = await aiosqlite.connect("main.db")
you can see if file.startswith("__") then dont load it
oo
should be good, one sec I'll look through aiosqlite docs
Currently the loop appends the extensions to list, is there a way to not do that add without breaking the loop
so... Result class is either undocumented or it doesn't exists..
continue keyword?
hm
will pass the rest of the code inside the loop and go to the next elem
Thats why i did thanks.fetchall()
if file.endswith('.py') and not file.startswith("__")
...#do stuff
else:
continue
So I am using pycord to create a discord bot, and I am trying to implement a verification for the users, through a message, under which you have to react with a tick.
But when I use the on_row_reaction_add function, I get a correct payload with the channel id, guild id, user id, and everything else. But when I try to get the member that made the reaction using the user_id from the payload, it just returns None. This is how I try to get the member:
member = self.get_user(payload.user_id)
ah yea, Connection.execute() returns Cursor object so your code is fine
sure
enable intents.members
So what is the problem
how do I do that?
what type is user_id? INTEGER?
ya
Yes.
yes
!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.
Bruh
thanks
can the bot see the emoji?
can you try do SELECT * FROM thxcounter just in case
its in the server
@visual island I've added the intents, and still doesn't work. For some reason it still returns None
this is working tho
Thats the code i have
wait.. u cant do that with custom emoji???
probably youre using a message's id instead of the emoji's id. How did you copy the emoji id?
i right click the emoji
lemme try again
show code where you load the intents
without the WHERE ...
Oh
906181459172282412-921026726304317470
thats the message id
yea
no
:/
rip it can't load extensions with that method
channelid-messageid
messageid
@visual island
:pogchop:
if you print member.id does it print the same id that's in the tuple?
why not
I keep getting "extesion alrd loaded", even after I stop the bot and restart it, why is that?
is it cached or smth
no
Yes
cache should be restarted after you stop the program
921028171145576478?
its not a custom emoji so None
hm
oo
show code
is there something like json but it uses lists instead of dicts?
no, but why
ext = []
for folder in os.listdir('MyBot/cogs/moderation'):
if folder.endswith('.py') and not folder.startswith("__"):
bot.load_extension(f"MyBot.cogs.moderation.{folder[:-3]}")
ext.append(f"MyBot.cogs.moderation.{folder[:-3]}")
else:
continue
for subfolder in os.listdir('MyBot/cogs/other'):
if subfolder.endswith('.py') and not subfolder.startswith("__"):
bot.load_extension(f"MyBot.cogs.other.{subfolder[:-3]}")
ext.append(f"MyBot.cogs.other.{subfolder[:-3]}")
else:
continue
you can just do things with json eg.
{
"list": [...]
}
dont do a nested loop there
It works with nested loop, why is that bad?
"it works"? You said it raised extension already loaded
I fixed it
I removed the bot.load_extension from loop, and loaded ext which is a list
YYes
the inner loop will be executed x times. x is the number of times of the outer loop got execute so it will load it multiple times
hm I see, so I should keep them seperate?
yes
need help with commands.MinimalHelpCommand, here's my code: https://paste.pythondiscord.com/jixatocale.properties
with args (help about a specific command) https://cdn.discordapp.com/attachments/381965515721146390/921026853504958504/unknown.png
!pypi jishaku
A discord.py extension including useful tools for bot development and debugging.
Are you using disnake?
ye
, your code is 100% correct
!pypi disnake-jishaku
I was just curious of what that was because I have seen it few times
[] means list, right? how do i make that list to show only the counter?
its a bot extension maintained by kraots
^^^
SELECT counter FROM table
one of the things it can do
you can also reload/unload extensions and many other stuff
log out to
for some reason logout doesnt work for me smoetimes 
weird mine does
it just auto logs back in after awhile
whats the issue
those are in build features, right?
nice
if i do .help command_name, it responds with plain text (although i have this:```py
async def send_command_help(self, command):
embed = discord.Embed(title=self.get_command_signature(command))
embed = discord.Embed(
title="Help",
color=COLOR,
timestamp=datetime.datetime.now()
)
embed.set_author(
name=self.context.bot.user.name,
icon_url=self.context.bot.user.display_avatar.url
)
alias = command.aliases
if alias:
embed.add_field(name="Aliases", value=", ".join(alias), inline=False)
channel = self.get_destination()
await channel.send(embed=embed)
```if i do .help without args then it'll send the embed (as it should)
it will show all the commands
so it's like disnake, but different name
which?
no its an extension
oo
so it wont change my code?
bot.load_extension("jishaku") even if you download the disnake version
no its an extension
nice
yep
maybe I could add that
maybe you have an external lib that changes the help command? Maybe jishaku?
pretty useful
hmm
yea?
let's see
!remind 23h read dis/install it
Sorry, you can't do that here!
Thats the new respond
brehh
so, its working?
now it's like this 
also how do i hide jishaku from help
thats the wanted output isn't it?
No.. I want to show it as one number like: 3
in that case, you have 3 results with that query, if you want 1 query only, then use fetchone()
also slice it to 0
cursor.fetchall() returns a list of tuples
indexing that output is fun
I want all to connect to one number
i guess i have a solution
igtg
for the Help field use command.description (I personally use command.callback.__doc__ hehe). And for the Aliases field your current code is right, just the command has no aliases
For the doc string?
yep
The long help text for the command.
Thatโs what I use atleast for doc strings.
it doesn't include indentation stuff iirc
oh?
