#discord-bots
1 messages · Page 1013 of 1
did u update it
env saves the day
80
okk
So? Now what?
...

ot
wait
?
what's ephemeral
Idk
it means the message is only seen by the end user and the message itsnt officially sent through the API as a discord message
Ask @quaint epoch
Oh
try removing it?
Sure.
@formal basin
1 sec
alrr
anyone know if you can hide the usage on slash commands
It’s loading
idk slash cmds sry
Set the usage value to None
Nope doesn’t work.
I believe it’s the description value in the decorator
Ohhhhh
yeah sorry wasn't really descriptive on that
I don’t believe you can change that
That’s built into discord
How can I add cooldowns to slash commands
It works but it won’t reply to the user saying that’s there on cooldown
Try on_error instead of on_command_error
!d discord.app_commands.checks.cooldown
@discord.app_commands.checks.cooldown(rate, per, *, key=...)```
A decorator that adds a cooldown to a command.
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns are based off of the `key` function provided. If a `key` is not provided then it defaults to a user-level cooldown. The `key` function must take a single parameter, the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.Interaction "discord.Interaction") and return a value that is used as a key to the internal cooldown mapping.
The `key` function can optionally be a coroutine.
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.app_commands.CommandOnCooldown "discord.app_commands.CommandOnCooldown") is raised to the error handlers.
Examples
Setting a one per 5 seconds per member cooldown on a command:
click the link to see the full example
not really. But the one I use, i haven't paid more than $1.10 a month. Not free but, pretty cheap
The problem is it won’t send the message
It puts it in the console for some reason
show ur code
because ur using the wrong namespace
Hm?
So what do I use
app_commands is not defined.
plus ur using on_command_error, thats not how its shown in the example
is this the wrong channel
what lib are u using?
because the documents I've shown are for discord.py 2.0
I’m not on 2.0
but ur using discord.py or something else?
then u have to upgrade to 2.0. slash commands are only in 2.0
But can you tell me how I can make it send that they are on a cooldown
I already have. 👉 #discord-bots message
That is 2.0 tho
Ohhhhh
I don’t understand it’s still not sending
Why is slash commands harder than normal commands
can i not annotate slash commands with discord.channel?
U can. Well, discord.TextChannel, assuming ur using discord.py
So what your saying is I can’t do a slash cooldown without 2.0
exactly, because anything and everything related to slash commands are only 2.0
It’s done but the problem is it’s putting in the console instead of the channel
i see that ur slash command above was slash.slash, and im pretty sure thats not discord.py. if ur using another lib then im not sure how to do the cooldown
Could you Dm your pfp, thanks
gg = json.loads(doxreq.text)```
UnboundLocalError: local variable 'json' referenced before assignment```
how to fix this error
Can you just explain to me why it won’t send the error in the Chat
xy-problem
The XY problem can be summarised as asking about your attempted solution, rather than your actual problem.
Often programmers will get distracted with a potential solution they've come up with, and will try asking for help getting it to work. However, it's possible this solution either wouldn't work as they expect, or there's a much better solution instead.
For more information and examples, see http://xyproblem.info/
Can you just explain to me why it won’t send the error in the Chat
Because I don’t understand why
What have I done wrong here it’s sending it in the console why can’t it send it in the chat
What u might have done wrong is that u could be using isinstance for the wrong parameter. Usually with slash commands, there's only the error and interaction, no ctx, so the library might not be passing the value ur expecting. when it comes to on_command_error, make sure parameters match because from what ive seen other libs do is
Regular command
async def on_command_error(ctx, error):
...
Slash command
async def on_slash_command_error(interaction, error):
...
Not what u have where its both ctx and an interaction. But it all depends on ur library of choice.
import json
dont know of any sorry. i searched up and down in the past for a free one but i just couldn't find a free AND reliable one. came to the conclusion that with stuff like VPS, ur gonna have to pay. unless u use heroku or replit (which u've stated u dont want to use)
should ask that in #965291480992321536, AWS is nice.. they give you a free trial
there is a error called init() missing 1 required keyword-only argument: 'intents'
i have tried googling but all of the answers dont work
what should i do?
Pass a kwarg to the class
!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.
👌
does anyone here know python json?
*discord.ApplicationCommandInteraction
How can i access the deleted image for permanent like i am using a event it send the deleted image after some time we are unable to access it
i dont think u can
Why other bots do
how do u know theyre deleted
ask in #python-discussion
you can't, discord limitation
what i do (since my bot is not public), i save it to my VPS server for an x amount of time. I name the file in the VPS server as the message ID, and using on_message_delete, I check the ID of the deleted message, compare it to the ones listed in my VPS server, if it matches, I can log the deleted image using the file from my VPS server
I don't even save them
can't we use BytesIO for it?
or they could save the deleted image's bytes and then convert it to an image
im pretty sure, yeah
I will try 
but then if ur bot restarts, all the data will be lost so thats the bad side @lyric apex
await attachment.to_file() and there you go, works fine for not heavy ones
The Image Will Be Sent In An embed already right?
If you need to resend the deleted message in logs for example
if its sent before the data is lost yeah. not after
is it possible to use context menus in cogs
since they require 2 parameters exactly
why does it not work?
length of new_prefix must be returning 0
so, to make optional arguments, you need to -
def foo(arg1, arg2=None):
if not arg2:
...
Why'd you need to make it optional tho
thats what I was thinking. it looks like that parameter should be required based on the command
how do i get time for a message? can you do message.time() or something like that? also preferably as accurate as possible
no, time for when the message was sent, not current time
!d discord.Message.created_at
property created_at```
The message’s creation time in UTC.
hmm
Yo
How does this guy just write code and then have it automatically update?
https://www.youtube.com/watch?v=hat8RVacNFs
Like he doesn't reload his code or any cogs
Nvm I found it, it's somethign called nodemon
TypeError: init() missing 1 required keyword-only argument: 'intents'
TypeError: init() missing 1 required keyword-only argument: 'intents'
how do i fix it?
guys i have this code
from datetime import datetime
import time as timeorsomething
import datetime as etad
start = timeorsomething.time_ns()
but i always get TypeError: 'datetime.datetime' object is not callable no matter what i import any of them as
oops
ment to put in general
I want to send a message to a server every 30 minutes What should I do?
is there a way to make discord bot which gives role when you have invite link in your status
help
any tutorial for discord.py buttons, dropdowns ?
Yes
!d discord.on_presence_update
discord.on_presence_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their presence.
This is called when one or more of the following things change:
• status
• activity...
with time? and a couple loops
welp
oh
how
damn
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
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").
Oh wrong person
Use this ^
No
It's just on_presence_update since you have already imported discord
I would hope so
@slate swan hi
It's on_presence_update regardless of u imported it or not
u didnt call View
u didnt create an instance of View before calling to_components()
Yes that's what i said
He just put view=SelectView that's why yeah
No brackets no object
View.to_components()
TypeError: View.to_components() missing 1 required positional argument: 'self'
Hello ryuga
hi
Look upside it's internal
How many guilds exe
how do i enable tracemalloc
you don't
Maybe a await issue?
vs code requires me to
Nevermind
no, you forgot to await something
How many guilds exe
@latent anchor you just didn't await something you don't need to enable it
You mean aias?
load extension cant be awaited
Yes?
it just showes this
RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
I forgot it's name
Well I got no host now
await the method
u need to await load_extension in dpy 2.0
Because free cloud hosting doesn't exist for russians now
Already got ubuntu server iso
it doesnt work cuz there is no async
Make it async then
async it as what
Async all setups

add_cog is async too?
!async
Concurrency in Python
Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the asyncio library, which is included in the Python standard library.
This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in other threads.
To call an async function we can either await it, or run it in an event loop which we get from asyncio.
To create a coroutine that can be used with asyncio we need to define a function using the async keyword:
async def main():
await something_awaitable()
Which means we can call await something_awaitable() directly from within the function. If this were a non-async function, it would raise the exception SyntaxError: 'await' outside async function
To run the top level async function from outside the event loop we need to use asyncio.run(), like this:
import asyncio
async def main():
await something_awaitable()
asyncio.run(main())
Note that in the asyncio.run(), where we appear to be calling main(), this does not execute the code in main. Rather, it creates and returns a new coroutine object (i.e main() is not main()) which is then handled and run by the event loop via asyncio.run().
To learn more about asyncio and its use, see the asyncio documentation.
yes
Yes
Read the gist
Then just make every fricking thing async
oh ok so i async it as main
If you don't host it will you ever make it open source
Ik I just don't use dpy 2.0
i sent a link, check that out ....
ummmm
Yes after I build a server

quack
yes i was looking at that
so many ducks 
Yes Hua, quack.
You can subclass bot and load all extensions in overridden start method @latent anchor
Do you have a question or a problem
Or do you want to discuss something
Music generation bot 😩
bot.start?
nope
ive seen it beofore but i didnt use it
class MyBot(commands.Bot):
async def start(self, *args, **kwargs):
# load extensions here
await super().start(*args, **kwargs)
bot = MyBot(...)```
That's not how you subclass but yes
You can make it low-level with asyncio but I think this is more convenient
they should load extensions in the setup_hook method
I have checked docs for that multiple times but couldn't find anything about that method, what does it do
I think it triggers when the bot starts?
it does nothing unless you override it https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.setup_hook
now the bot can run but it cannnot load extensions and react to messages
Not quite sure since i don't use discord.py 2.0 and don't have to await extensions
Ok thanks

Don't tell me you just copypasted code I gave you
no i didnt lol
And yeah as @boreal ravine said it should be
class MyBot(commands.Bot):
async def setup_hook(self):
await self.load_extension("ext.ext1")
# and so on if not use listdir which is better ofc```
import discord
import randfacts
import requests
from discord import Intents
intents = discord.Intents.default()
intents.typing = True
intents.presences = False
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print('Running...'.format(client))
@client.event
async def on_message(message):
request = requests.get(url='https://catfact.ninja/fact?max_length=140')
if message.author.bot:
return
if message.author == client.user:
return
elif message.content.startswith('.catfact'):
await message.reply(f"The cat fact is: {request.json()['fact']}")
elif message.content == '.meh':
await message.reply(".meh")
elif message.content.startswith('.fact'):
await message.reply(f"The random fact is: {randfacts.get_fact()}")
the bot is running but not answering
i have done something wrong but idk what it is
hey skevvy
Kek hello
umm.. why are you getting reuqests in on_message plus ur using requests so its blocking
🤔 lets say i want to send send a post in a discord channel which automatically gets posted to reddit
how do i go about it?
bc if u put the request outside the def it stays the same
i need it to change every time u press .catfact
make a command
it used to work but for some reason it stopped
sending requests especially with a blocking lib like requests is slow
make a command and name it catfact
so that u send minimal requests
i am not very good with these
what do u mean?
so i should remove the request = requests.get(url) from the def
could u show me what u mean please? if its not 2 much trouble
yea, remove it from on_message, so discord.py has this called commands they get called everything someone types <prefix><command_name>
import discord
from discord.ext import commands
@bot.command(name="name here if you want a different one than the function name", description="describe it here", hidden=False) #set hidden to True to hide it in the help
async def mycommand(ctx, argument1, argument2):
'''A longer description of the command
Usage example:
!mycommand hi 1
'''
await ctx.send(f"Got {argument1} and {argument2}")
this is an example of basic command
sorry i am not very good at it xd
i didnt understand what should i put in the description
and inside the mycommand

xd
this is description
or you can custom help command
u dont need to put anything in the desc, its optional
and neither in name?
the thing u want to happen after someone types .catfact
if message.author.bot:
return
if message.author == client.user:
return
elif message.content.startswith('.catfact'):
await message.reply(f"The cat fact is: {request.json()['fact']}")
elif message.content == '.meh':
await message.reply(".meh")
elif message.content.startswith('.fact'):
await message.reply(f"The random fact is: {randfacts.get_fact()}")
ya name the command catfact for now, but its good practice to do that in name
so this
basic command is
@bot.command()
async def say(ctx, *, msg=None):
await ctx.send(msg)
What tutorial are you using?
i am not using tutorial
3 elif :v
yea i removed 2 of em

Client does not support commands
#Importing the Required Libraries
import discord
from discord.ext import commands
intents = discord.Intents.default() #Defining the intents for the application
intents.message_content = True #Required for Discord.py 2.0 | Enabling the message_content intent so as to make the *prefix* commands work
intents.members = True #Enabling the members intent to get permissions to view their info using our app
bot = commands.Bot(command_prefix="!", intents=intents, description="A Basic Bot based on Discord.py 2.0", activity=discord.Game(name="with you"), status=discord.Status.idle) #Defining the Bot
@bot.listen("on_ready") #A decorator to register a function as an event listener. In our case, this will print something when our bot is successfully connected to the discord api gateway and ready to use
async def on_ready():
print(f"{bot.user} is online!")
@bot.command(name="ping", description="Get the ping of the bot") #A decorator to register the function as a command for the bot
async def _ping(ctx: commands.Context): #initiating the command function. The logic inside this function will determine the behaviour of the command
await ctx.send(f"My ping is {round(bot.latency) * 1000}ms!") #sending back a response. Here, sending the bot's latency back to the author
@bot.command(name="embed", description="Embed any text")
async def _embed(ctx: commands.Context, *text: str):
embed = discord.Embed(description=text, color=ctx.author.color) #making an embed
await ctx.send(embed=embed) #sending the embed using the *embed* kwarg in the *send* method
bot.run("token") #running the bot. Pass your bot's token into the *run* method.
Here's a short example
ohh ok tyvm
yoinks
what
anyone new user who stumbles on that code
wdym
Practically gave the code for making a commands.Bot bot
yeah....its not even useful-
I was going through all of the code to see if there was any uwus
no thanks, I've put that stuff in a bot, so that i dont have to write all of the code anytime again
The uwus?
How can i make a bot without prefix?
Man whenever i say uwu i always think of the woohoo from the sims
Use discord.Client?
Or just commands.Bot with only on_message
Like it funtion with prefix if used and if not prefix selected peeps can use it @supple thorn
no lol, all that code....
What
I am saying that some selected person can use bot without prefix
How will i do that
How will the commands look like then?!
I mean- how do you use the bot without a prefix?
Why would you want this
☠️
I am wanting something unique in bot features so
slash commands
That’s basically a / prefix
If they want to do it without a prefix then you don’t want slash commands
huh? thats the only option except user_commands
That's distinctly different from message commands with one person being able to "use bot without prefix" if I understand things correctly
Wyo
From all of the things i guessed that was in your wishlist
Elden ring was not one of them
" a bot without a prefix will most probably refer to app commands "
cuz i see no other way to use a bot without a prefix
I don’t even want it ☠️
Why the hell do you have it in your wishlist then
Idfk
Free game 🤷♂️
async def on_member_join(self, member):```
i want to extract member's avatar url, i am using this
`embed.set_thumbnail(url=member.avatar_url)`
but it is throwing error
Make a prefix function that will return empty string for that user
Ez
Are you on 2.0?
yes
I Didn't understand
If you add female blunt 6' objects i'll try to see if one my delusional money friends will buy it for you
lmaooooo
!d discord.ext.commands.Bot.command_prefix read about the function you can parse to there @lyric apex
The command prefix is what the message content must contain initially
to have a command invoked. This prefix could either be a string to
indicate what the prefix should be, or a callable that takes in the bot
as its first parameter and discord.Message as its second
parameter and returns the prefix. This is to facilitate “dynamic”
command prefixes. This callable can be either a regular function or
a coroutine...
What
Didn't sync yet
I am not going to add that to my wishlist because the shit is going to my friends house so I can pick it up
Don’t think they would appreciate a “toy” at their door
Why your friends house
Never changed it
How about fake female mammary glands
thanks for telling
Tits?
Yes
I’m allready on the verge of getting the shit beaten out of me so I don’t think that’s a very good idea
@slate swan anyways try to wait for ~1 hour and see if your commands appear also make sure you authorised your bot with application.commands scope
How about a wheelchair
Nah ☠️
As for pycord I have no idea what you can do else
A fake boyfriend?
My real one is enough
Moyai
My bad
Its Not working
How can i make this for a channel or user only?
!d discord.ext.commands.Bot.check_once
@check_once```
A decorator that adds a “call once” global check to the bot.
Unlike regular global checks, this one is called only once
per [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") call...
Check the author's id and see if it matches the one you want to let use that horrific prefix
Bro my bot responds to -help But it doesn't Responds to -Help can i make it work without making aliases for it?
Thanks soo much it works
Hello
You use aliases
No way without alias?
Oh wait nevermind
!d discord.ext.commands.Bot.case_insensitive
Whether the commands should be case insensitive. Defaults to False. This
attribute does not carry over to groups. You must set it to every group if
you require group commands to be case insensitive as well.
I don't know why i thought this was for the prefix
Why?
example py async def testcmd(ctx, *, hi, hello) await ctx.send(f'you said {hi} and {hello}' )
i want it like this
@supple thorn
Missed a '
just an example
Yes what are you showing me
but how would u make multiple contexts
Looks like a simple snippet of a test command
Why though
long story but is it possilbe
!d discord.ext.commands.Bot.get_context
await get_context(origin, /, *, cls=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Returns the invocation context from the message or interaction.
This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands")
to allow users more fine grained control over the processing...
You can get different context from messages
i want multiple variables
Yes you can assign them to different variables
And just use them like ctx
poopybutthole = await bot.get_context(message)
interesting name
for?
You said it was interesting
oh 👍
Yo
I am unable to do it can you explain me with an example?
cat 
#965291480992321536 is a better place to ask.
What works
discord bot i made
What made it not work
my stupidity xd
There is an example in the docs if you click the hyperlink
@bot.check_once
def whitelist(ctx):
return ctx.message.author.id in my_whitelist
Here is the example from the docs
@bot.check_once
def whitelist(ctx):
my_whitelist = "680994218977787927"
return ctx.message.author.id in my_whitelist```
I used this it return left side uses string not int*
What
Also ctx.author.id is an int
You're comparing a string to an int
Remove the ""
why the heck is this giving me self.load_extension('jishaku')
this error - Extension 'jishaku' raised an error: TypeError: cogs must derive from Cog
jishaku is not a valid file name
then how do I load it
I even tried the ways that the docs suggested
smh
@supple thorn
i think u need a file called jishaku where u need to import jishaku and have a setup function init
https://discord.com/developers/applications add a description to the application
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
no luck, same error
are you using disnake?
*u changed it
Hi im back
sup back
yes.....
is it only compatible with dpy.....smh
whats jishaku? carrots jsk? gorialis's jsk?
sadly yes
!pip jishaku
A discord.py extension including useful tools for bot development and debugging.
uhhhhhhhhhh
Bruh 😆
Sounds like anime
gorialis's
Maybe a non printable character?
Happens when you copy code in a codebloco from discord
!pip disnake-jishaku
wow
use that one
thanks a lot
Traceback (most recent call last):
File "C:\Users\xylo7\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "azure2.py", line 231, in on_ready
members = guildobj.members
AttributeError: 'NoneType' object has no attribute 'members'
``` any help?
Send ur code
@client.event
async def on_ready():
os.system('cls||clear')
global members
members = guildobj.members```
wait, so do I just load it? I dont need to do anything else....?
What are u trying to do??
yeah make sure u yeet old jsk
did that already, now the jsk commands dont even work oof
You use jishaku?
get all the members in a guild
trying it
never used it before
Oh
Welp ima sleep
Quack you guys later
Did they load succesfully?
yeah they did
ay jishaku is kinda cool
Do they show up in the help command?
only if I do !help jsk/jishaku
I mean, they dont anymore*
any help?
guild.members
@maiden fable like it doesnt show up in the help command, but when I pass the subcommand, it does show
I think
!d discord.Guild.members
property members```
A list of members that belong to this guild.
and guils should be a guild obj like guild = client.get_guild(id) right
yes
Yes
ok but im gettinf an err with that code
^
^
It hasn’t found the guild
cmd = commands.Command(asyncio.coroutine(lambda ctx: ctx.send(1)), name='hi')
one liner ez
If it doesn’t find the guild it returns none type
@boreal ravine 😔 help
yh buit i also have py try: client.get_guild(id) except: print("Error")
above it and it doesnt print err
maybe its hidden idk
Because it doesn’t throw an error
It returns a none type
It handles it for you
smhhhh
the commands dont even work
how can i make it so that when a message is sent in a specific channel the bot messages them
oh ok so is there a certain place i should put this code?
errors?
wait.for
@bot.event
async def on_message(message):
if (message.channel.id == 'channel id'):
await message.channel.send('message goes here')
on_message event with channel check
idk how i could use it in this context
channel IDs are integers, not strings
i just copied a guy xd
Check your guild id
im 100% sure its valid
Bad practice
i checke like 10x
And is it an integer or a string
yup
ok so im suppose to know by heart
message.channel.id == 12321313
or
No you can copy the channel id
Copying someone’s Code is bad practice because you don’t fully understand it so you won’t be able to fix any errors caused by it
I UNDERSTAND
channel.id == 1324134124
bro stop
hm
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))
i havr the id defined as int(input())
That’s the code for a presence object
Ok
is there anything else that could be wrong?
Try bot.fetch_channel instead
how do i change the actual name of the help command
like i want to have the help command work when someone says !assist instead of !help
bot.wait_for(...)
help_command=“assist” I believe in the Bot constructor
That’s a wild guess
oh ok
who has a link to discord.py the new version, and that is 3.8
preferably a link to the git hub
msg = await bot.wait_for(event = 'message', check = check, timeout = 60.0)
would something like this work
ERROR: Cannot unpack file C:\Users\ToxicPenguin\AppData\Local\Temp\pip-unpack-7y59g8v3\discord.py (downloaded from C:\Users\ToxicPenguin\AppData\Local\Temp\pip-req-build-zts93rgu, content-type: text/html; charset=utf-8); cannot detect
archive format
ERROR: Cannot determine archive format of C:\Users\ToxicPenguin\AppData\Local\Temp\pip-req-build-zts93rgu
@sick birch not working
@slate swan it didnt work
who has a link to discord.py the new version, and that is 3.8
preferably a link to the git hub
who has a link to discord.py the new version, and that is 3.8
preferably a link to the git hub
Raptzz GitHub
There are example views
Check confirm.py for a deatailed example of buttons
bot = commands.bot(‘!’, help_command=None)
@bot.command()
async def assist(ctx):
await ctx.send(commands.Command.help)
TYSM :))) @slate swan
@slate swan you have a link to the github where there is ... the version on which the buttons work ?
Raptzz
if (message.channel.id == 969964701679231006):
msg = await bot.wait_for('message')
how to make it so that after the bot waits
it sends something to the user that sent the message
check=check probably
@slate swan Are you kidding me?
archive format
ERROR: Cannot determine archive format of C:\Users\ToxicPenguin\AppData\Local\Temp\pip-req-build-il6u2836```
ERROR: Command errored out with exit status 1: git checkout -q rewrite Check the logs for full command output.
WARNING: You are using pip version 21.2.2; however, version 22.0.4 is available.
You should consider upgrading via the 'c:\users\toxicpenguin\appdata\local\programs\python\python39\python.exe -m pip install --upgrade pip' command.```
pip install -U git+https://github.com/Rapptz/discord.py
Try that instead
@slate swan OMG now my bot doesn't start stupidly
That's what it should do
how to make user specific prefix?
@slate swan File "c:\Users\ToxicPenguin\Desktop\disocrd bot python\index.py", line 8, in <module> bot = commands.Bot (command_prefix = ',') TypeError: __init__() missing 1 required keyword-only argument: 'intents'
then why arent the commands working-
Add intents
U got an error handler without an else clause?
how? it didn't need to be added before
It requires that you have them for some reason 💀
!d discord.ext.commands.Bot.intents
property intents```
The intents configured for this connection.
New in version 1.5.
!d discord.Intents.all
classmethod all()```
A factory method that creates a [`Intents`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents "discord.Intents") with everything enabled.
nvm, I forgot to raise the error at the end 😔
and now I know what the error is
bitch what the hell when I install a new version of python everything breaks!? What the fuck is this discord.py !? Why the fuck can't he install a new version just through pip install discord.py , and installs an outdated fuck. To understand this Discord.py who should I be!?
Calm down tbh
already pisses me off. These damn buttons came out 100 years ago, and in discord.py this shit only works with the version "I fucked the mother of this motherfucker who invented this shit!!!"
Your not making any sense, don’t cry about it Ffs.
how is it normal to say something here?
there is a meaning, but only Russian will understand this meaning
I'm gonna ping mods if you don't stop
because if u just do normal pip install it, it takes the files from PyPI. Only GitHub has the updated files
Nothing against tos
do you think this is appropriate
Yeah tbh
and then fuck this pip if there 's outdated shit ?
Bros got beef with pip ☠️
💀
@heady sluice yes.
wanna find out?
bro if you have a problem with pip no one can help 💀
yes (for now). discord.py 2.0 hasn't officially released, so thats why when u do a normal pip install, u get the old files, aka version 1.7.3
He ain’t even got a problem with it, he’s just ranting about it’s giving him outdated shit
@slate swanshow code
@silver wolfyes discord.py not officially. But the functions are already on discord.py figs understand which version that does not work on this 1.7.3
What ☠️
"already on discord.py figs", what does that mean?
what library are u using
show ur code for the slash command
hm, does disnake modals allow multi-line input?
one will suffice
because its set as global. which takes about an hour for it to show up. if u want to use it right away, u have to specify the guild to which it can be used
@bot.slash_command(guild_ids=[...])
async def shop(ctx, ...):
...
exactly, so u need to do testing in a single server, because nobody wants to wait an hour just to make sure their code is working properly. when testing, test in a specific guild, when live, then set it as global
specific guild = right away
all guilds = about 1 hour
just ping me here. i'll be online

how would I get the channel ID when a command is used
ah yeah
should of looked at the structure for ctx
:(
I stg I’m gonna fucking
Returns the channel associated with this context’s command.
Shorthand for Message.channel.
The channel ID.
Yeah yeah whatever
that depends on how many commands he/she has
and how many guilds to bot is in
Why don't I have an icon and the exact time?
Don’t ask that here since it has nothing to do with this channel, nothing to do with python in fact
Souly discord rich presence with visual studio code
Hello what i do? " ModuleNotFoundError: No module named 'discord' "
Restart your IDE if you have just downloaded discord.py
it is related to IDE for python
It’s not for python
Example:
IDE ?
what is it ?
Still nothing to do with this discord server but you need a discord rich presence extension
https://marketplace.visualstudio.com/items?itemName=LeonardSSH.vscord here is another one
first one is better option i beleive
but still it has nothing to do with this server
Restart visual studio code
Import "discord" could not be resolved Pylance(reportMissingImports) [Ln 2, Col 8]
Have you restarted vsc
yes
hm
Reinstall the module
pip3 install discord ?
ye
nothing
nothing?
again Import "discord" could not be resolved Pylance(reportMissingImports) [Ln 2, Col 8]
How can I host my bot in android 😔
are you doing it in the command prompt?
Or heroku or aws
in android os
I mean
there are python interpreters on anroid
Not those shity
sites
Pydroid 3 – IDE for Python 3
thats a python IDE for android
telling or askn
yes
go to C:\Users\AppData\Local\Programs\Python\Python37\Lib\site-packages
Ok
i don't find
press win+r and type "appdata" and naviagate from there
!e
import os
print(os.name)
i don't have python37 but python 310
:")
yeah thats fine

i'm in
!e
import os
print(os.name)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
posix
👀
?
.
i have discord.py-1.7.3.dist-info
drag that into Lib
ok
Then restart your IDE and try again
@setlang.error
async def on_command_error(self,error, ctx):
if isinstance(error, MissingPermissions):
await ctx.send("You dont have all permission for this command")
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Utility' raised an error: AttributeError: 'CogCommandObject' object has no attribute 'error'
Use termux
class SomeCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
async def cog_command_error(self, ctx, error): # no need for a decorator
... # handle errors here
why c?
thats a cog-specific error handler, not a command specific?
it still doesn't work :/
when was cog_command_error added?
pip uninstall discord
!d discord.ext.commands.Cog.cog_command_error
await cog_command_error(ctx, error)```
A special method that is called whenever an error
is dispatched inside this cog.
This is similar to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") except only applying
to the commands inside this cog.
This **must** be a coroutine.
yes
pip install discord

mmh no
no module named discord
whats the issue?
He cant import discord
Make sure that,
- you have restarted your code/text editor
- you have the correct python version selected
wrong reply but nvm
wait there is CogMeta, now imma make overloading for commands 
what kind of formatting is this
c
!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.
...
Once you help everyone there is noone else to help 
well
well 🗿
alr
🥲
oh ok
Hi
yo
!e
import __hello__
@slate swan :white_check_mark: Your eval job has completed with return code 0.
Hello world!
i am different
print("roses are red, violet are blue")
(unexpected lines 32)
bro
😭
!e ```py
string = "hello world!"
list = []
for letter in string:
list.append(letter)
print("".join(list))
bro😳
@slate swan :white_check_mark: Your eval job has completed with return code 0.
hello world!
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | KeyError: 3
py -m pip install discord
Guys, how can i set error to slash in cogs? if i use @command.error
Output:
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Utility' raised an error: AttributeError: 'CogCommandObject' object has no attribute 'error'
i said earlier

i want to print the status of my discord bot
the problem is same for your code, its so sad
ex: online, dnd, invisible and idle
just print the kwarg of your bot instance the status class should have a repr dunder
give me an example or else ill bust
what?
😭
🔫
dont give him that example
i beg

bot = commands.Bot("!")
print(bot.status)
xd i have not tried that
!d discord.Member.status
property status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") instead.
chill out 💀 😆
OK ELON
!e
class A():
def __init__(self, name: str):
self.name = name
print(A("bob").name)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
bob
You vs Femboy
you do know thats not how stuff works right?
what ☠️
yes 🙏
member.status would probably work
How i get user mentioned ban reason , my code sends all guild banned members
but bot.status doesnt
you give a method of the member class and then pass it to the bot class thats worse than my wording💀
lmfao as said

bot.user.status
sorry 😭
xd
doesnt that return a ClientUser
🗿
File "/home/maxmorin/Downloads/roro/main.py", line 44, in <module>
print(bot.user.status)
AttributeError: 'NoneType' object has no attribute 'status'```
Compare user IDs, and you probably want to change the name of your variable to something like banned_user = ban_entry.reason so that you don't overwrite
the user isnt signed in yet
!d discord.ext.commands.Bot.user
property user```
Represents the connected client. `None` if not logged in.
i know my stuff
no
How do i do it in a single iterable
discord.on_connect()```
Called when the client has successfully connected to Discord. This is not
the same as the client being fully prepared, see [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready") for that.
The warnings on [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready") also apply.
underneath on ready?
You don't. You compare the ID of banned_user with the ID of the user you gave in the parameters. Simple loop break to then stop the iteration and send your final embed.
and krypton long time no see🙀
idk what i did that for tbh 💀

And I don't regret my pause I've had
i leant something

I need help with this, if someone writes !daykey 1 it sends me a log to my webhook saying this person did that command
Check discord.py http structure
send link
from discord import Webhook, RequestsWebhookAdapter # Importing discord.Webhook and discord.RequestsWebhookAdapter
webhook = Webhook.from_url('webhook-url-here', adapter=RequestsWebhookAdapter()) # Initializing webhook
webhook.send(content="Hello World") # Executing webhook.```
thats good how youve been
what
idk what to call it mf
!d discord.Webhook
class discord.Webhook```
Represents an asynchronous Discord webhook.
Webhooks are a form to send messages to channels in Discord without a
bot user or authentication...
that whole sentence gave me a stroke😭
lmaoo

if message.content.lower == '!daykey 1':
webhook = Webhook.from_url('webhook-url-here', adapter=RequestsWebhookAdapter()) # Initializing webhook
webhook.send(content="Hello World") # Executing webhook.```
would it be that?
😭
mf using on_message for commands 💀
because if !daykey 1 is written i went it to send me a message to a webhook sir
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
use commands :3
!d discord.ext.commands
No documentation found for the requested symbol.
:(
Good, lots of stuff going on but surviving
You?
😭
tryna show example
ok 😭
#some imports
import discord
from discord.ext import commands
@bot.command(name="name here if you want a different one than the function name", description="describe it here", hidden=False) #set hidden to True to hide it in the help
async def mycommand(ctx, argument1, argument2):
'''A longer description of the command
Usage example:
!mycommand hi 1
'''
await ctx.send(f"Got {argument1} and {argument2}")
ight send it
from discord import Webhook, RequestsWebhookAdapter # Importing discord.Webhook and discord.RequestsWebhookAdapter
webhook = Webhook.from_url('webhook-url-here', adapter=RequestsWebhookAdapter()) # Initializing webhook
webhook.send(content="Hello World") # Executing webhook.```
🤨
LMAO if !daykey 1 if written i want the url to be sent
i said that so wrong holy
if !daykey 1 is written it sents a message to the webhook
mhm nice, im doing good

from discord import Webhook, RequestsWebhookAdapter
webhook = Webhook.from_url('webhook-url-here', adapter=RequestsWebhookAdapter())
@bot.command()
async def daykey(ctx, arg):
if arg == 1:
webhook.send(content="command was used")```
ty
arg will never be 1 if you don't type hint it to an integer (arg: int)
and webhook.send is a coro
!d discord.Webhook.send
await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., ...)```
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)`...
God I hate Python 
need help with a music bot ?
as in i need help xD
Maybe in the other hand you do?
no
yes
!ydtl
Ask your question, we will see if we can answer
something about that
Don't just make direct suppositions. Playing a local mp3 file is not against any rule and can be considered as a music bot.
find all the wierd loopholes so we can help you with your music bot without getting a mods dick up our arseholes
!!!
wym ?
Just ask your question :)
oh okay
We will then see if we can answer it
i keep getting this error
How do i make User specific prefix i am confused so much
cog needs to be cap ?
you dont 
Well now it goes to the ytdl tag unfortunately we cannot help
!ytdl
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)
you cant use ytdl ?
you can but it it breaks the TOS (youtube's)
its the same premise of guild specific prefixes
what can i do instead
You can, it's just beaching terms of service of YouTube and we don't provide help to breach terms of services.
bc i got this whole code

There's nothing you can do, simply don't make a music bot and use what other bots can offer
this is all wrong
delete that message now
....
thanks
how is it wrong ?
The easiest way would be to subclass your bot, then write a get_prefix method bound to the class. For an example, py async def get_prefix(self, message: discord.Message) -> str: return "prefix" Now to actually make it user specific, check message.author.id then determine which prefix to return from that.
As already said, you won't really get any help as we don't help for projects that breach the terms of services.
json 😭
why because of async infecting almost every method?
well is there a way to make a music bot without ytdl ?
Not only this 
That isn't really specific to python though.

it is tho
Streaming music from YouTube and other services is prohibited. It's not about the library you use
if you don't want to subclassing you could do this
async def get_prefix(bot: commands.Bot, message: discord.Message):
return "prefix"
bot = commands.Bot(command_prefix=get_prefix)
How so?
is there?
how ?
thats annoying
js has that advance async which lets you call promises in non promises
and other services
you can get music from elsewhere
spotify ?
You can also do that in python...
copyright
ik
without an AbstractEventLoop*
Almost all music providers do not allow music streaming and downloading.
if a command is sending a message to my webhook, how can i @ the user who did the command?
You can't really do a music bot without breaching a terms of service.
oh well
ctx.author.mention
!d discord.Member.mention
property mention```
Returns a string that allows you to mention the member.
Not sure how that has to do with your point though? All code bases are easy to infect with asynchronous code regardless of the language. That's just the nature of the paradigm itself
regardless of the language
Not really no
async def function():
...
coro = function()
try:
while True:
coro.send(None)
except StopAsyncIteration:
pass
i would disagree
On what basis
already said it lol

webhook.send(content="Day key has been created" + {ctx.author.mention})
!f-strings
when i do that command it doesn;t work
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
any fixes for that
Yes, read the message above sent by the bot
@bot.command()
async def calculator(ctx):
m = await ctx.send(content='Loading Calculators...')
expression = 'None'
delta = datetime.datetime.utcnow() + datetime.timedelta(minutes=5)
e = discord.Embed(title=f'{ctx.author.name}\'s calculator | {ctx.author.id}', description=expression,
timestamp=delta)
await m.edit(components=buttons, embed=e)
while m.created_at < delta:
res = await bot.wait_for('button_click')
if res.author.id == int(res.message.embeds[0].title.split('|')[1]) and res.message.embeds[
0].timestamp < delta:
expression = res.message.embeds[0].description
if expression == 'None' or expression == 'An error occurred.':
expression = ''
if res.component.label == 'Exit':
await res.respond(content='Calculator Closed', type=7)
break
elif res.component.label == '←':
expression = expression[:-1]
elif res.component.label == 'Clear':
expression = 'None'
elif res.component.label == '=':
expression = calculate(expression)
else:
expression += res.component.label
f = discord.Embed(title=f'{res.author.name}\'s calculator|{res.author.id}', description=expression,
timestamp=delta)
await res.respond(content='', embed=f, components=buttons, type=7)```
Tbh we don’t speak Russian
