#discord-bots
1 messages · Page 12 of 1
yep both of those are on
Though it will happen again, so be careful (even if you are, not much you can do) since temporary bans will eventually lead up a to a permanent ban @slate swan
wait so can you help me setup the vps and i wont get banned right?
Right, post any specific problems you may have in #965291480992321536 and either I or someone else will help you out
@sick birch yessir
so this will be fine for the discord hosting right?
Standard 1GB
Lightning
$3
/month
1 vCPU
1 GB Ram
15 GB NVME Storage
1 Gbps Down / 100 Mbps Up
Private Networking
Unmetered Bandwidth
Weekly Backups
Live chat support
will that be good enough for hosting my discord bot @sick birch
They're all good, but picking is up to you as you're the one making the purchase, not me
so why does this code throw the following error?
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
channel_id = 795498638951579648
channel = client.get_channel(channel_id)
await channel.connect()
guild_id = 710691259009990686
print(bot)
guild = await bot.fetch_guild(guild_id)
voice_client = discord.Guild.voice_client()
voice_client.play(discord.FFmpegPCMAudio(executable="ffmpeg//bin//ffmpeg.exe", source="barack.mp3"))```
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\Alex\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\python\Audio\discord_bot.py", line 40, in on_ready
guild = await bot.fetch_guild(guild_id)
File "C:\Users\Alex\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 1188, in fetch_guild
data = await self.http.get_guild(guild_id)
File "C:\Users\Alex\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 192, in request
async with self.__session.request(method, url, **kwargs) as r:
AttributeError: 'NoneType' object has no attribute 'request'```
Im just asking if that will run my bot good the one i just sent
It will, until it starts growing
Is there any free websties like replit that wont get me banned?
How i can send message to channel from another thred
why do you have both bot and client
Q .How to send message through discord bot ??
I have 2 thred running
1st is discord
And 2nd is for something other
I want to send message through another thread how i would do that.
I'm gonna level with you, I know very little about discord.py
all this code was frankensteined together from stackoverflow posts
I don't know what I'm doing
does everyone still use discord.py?
Q .How to send message through discord bot ??
I have 2 thred running
1st is discord
And 2nd is for something other
I want to send message through 2nd thread how i would do that.
you need to choose either between bot or client, it depends on what you set the variable
I think you are using client
I don't know what any of this means. I just want the bot to join the voice channel and then play an audio clip whenever a certain function is called
depends on when you want the message to be sent
your variables names aren't consistent basically
Does anybody know a good site i can host my bot on?
you need some other code in the top btw
oh this?
load_dotenv('discord_bot.env')
TOKEN = os.getenv('DISCORD_TOKEN')
bot = commands.Bot(command_prefix="!", intents=intents)
client = discord.Client()```
Does anybody know a good site i can host my bot on? please answer
yeah
if you have replit hacker plan I guess its ok
$7 a month
you are using both bot and client I think
ill buy it what does hacker plan do? whats better
you familiar with replit?
What Wiil be code in another thread to send message
not really
?
Google it
google what?
https://replit.com/ basically its an online ide
Replit
what does this mean? what do I need to change about my code?
delete the 5th line but then you need to change a lot of variables
tbh any vps is better than repl
can you explain more? which one are you counting as the fifth line? what will I need to change
I don't really use hosting so I don't know exactly
I guess thats what threads are for
so what he means is
Could you show me how to setup a vps if i bought one or nah if not ill buy replit
Is discord.py still alive?
I suggest you go check the discord-bot-hosting thread under this channel
you have a bot and client in your code and you only need one of those two
Send another friend request i didn't mean to decline
dang I need to keep up with the news
do you still need to use external libraries to do buttons and all that good stuff
no
thank god
they are in discord.py now
ok but why is my code throwing errors instead of playing the mp3 file?
and how does having bot and client cause that?
your code is a mix of using both client and bot, when you delete one, the other won't work.
but you also can't use both
because you need to start from something simple to learn programming, not copy code from the internet and expect it to just work
so what am I supposed to do
I guess thats the easy way to explain it
just delete one of the lines and replace all of the variables with it
Guys how can I remove a slash comamnd for servers? Of my bot?
a bot you created?
I can't delete the line that defines the client
cause then this throws an error @client.event
then you replace client with bot
bot.event?
yeah
you cant prevent syncing from certain guilds, however you can enable syncing in certain servers only
I want to unregister all my bot slash commands
ok I changed it to @bot.event and now the on_ready function never runs
comment out all the commands and sync your commands
can I see your code so far
I can't really help without it
@bot.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
channel_id = 795498638951579648
channel = client.get_channel(channel_id)
await channel.connect()
guild_id = 710691259009990686
guild = await bot.fetch_guild(guild_id)
voice_client = discord.Guild.voice_client()
voice_client.play(discord.FFmpegPCMAudio(executable="ffmpeg//bin//ffmpeg.exe", source="barack.mp3"))
client.run(TOKEN)```
DON'T DO SHIT IN ON_READY
yeah its gonna mess things up
I'm open to suggestions
make a command to run that
that will never run 9 outta 10 times
Oh k
Thanks
will a command allow me to call it from script?
or can only users call commands
you can make a task
ok how do you make a task
How can I make my slash comamnd work in all guilds?
from discord.ext import tasks
@tasks.loop(minutes=10)
async def task():
...
task.start()
bot.run()
sync without mentioning any guild ids
Ok
wait but this isn't something I can call is it
?
it just runs automatically every ten minutes?
yeah
if you want it to be something you call, you just create a command
once you start it
don't you have to type commands in a text channel
@bot.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
@bot.command()
async def command_name(ctx):
#code
bot.run(TOKEN)
yeah
you can't just call them from script
eventually it will stop running without hosting I guess
my goal here is to have a script I wrote that listens to my microphone input and detects keywords
commands -> you'll have to invoke from a text channel manually
task -> you can start/stop a task from anyhwere in your code
and when it detects a certain keyword, I want an audio clip to play in the voice channel
I think discord doesn't allow bots to listen to other people
dpy doesnt have voice receive yet 
not other people
discord does
I said my mic
wait does djs have voice receive
yep
and I already wrote that script
it's not a discord.py script
oh cool can I steal it
anyways you can use a task
I mean I haven't written the regex that looks for keywords yet, but that shouldn't be too tricky
import speech_recognition as sr
recognizer = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
recognizer.adjust_for_ambient_noise(source)
audio = recognizer.listen(source)
try:
print("Recognizing...")
query = recognizer.recognize_google(audio)
except sr.UnknownValueError:
print("Could not understand audio")
print(query.lower())```
in the task you can create an if statement to check if you want to run the code or not
I don't know anything else
oh wait, wtf
was this from a youtube tutorial...
istg I watched a tutorial like 2 years ago and the code was just like that
that code makes me wanna shit in my pants 
I got this error
dont create a new tree 
Hmmm
replit mobile 0-0
I mean I didn't write the speech_recognition module if that's what your asking
understandable
I not able to understand what you mean
I think that means delete that line of code
Hmmm
is there a way to make a task that loops constantly?
Ye now it worked
instead of running at periodic intervals?
if you do that discord won't be very happy and rate limit you
ok then is there a way to just... like... call functions in discord.py?
like just
if condition happens:
play_audio_in_voice_channel()
I made a command and it's coming interaction failed
code
Me?
you can make it do that in the task
yeah
Ok
and the task can be set to run to the minimum (rate limit time)
Why not
but then wouldn't there be significant lag time in between when my script calls the function and when it actually happens?
yeah but thats kinda the only way
test it out, don't think so
depends
you just have to be lucky a bit maybe
Why are you redefining prefix in the cog
What?
what do you mean what
I've never seen anyone add that to a cog
super().__init__(command_prefix=">",help_command=None,intents=discord.Intents.all())
you're sure there's no way to call commands from script?
that seems ridiculous that you couldn't do that
wait its loading
Wdym?
Bruh bro
That's subclass not cog
I just want a function that I can call normally, not like an async blocking function or whatever
Ah
that way when my other script detects a certain word, it can play an audio clip
!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/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
on_message listen?
but that's a bad practice in your case
message? I won't be using text channels at all for this
it'll all be done from script
what's your goal here
I speak a certain word into my mic
the code I wrote will pick up that word and call a function
that function will play an audio clip in the voice channel that I'm in
I have everything except the last step
Ahh I don't know of any way that wouldn't be blocking..
@slate swan got any idea?
it will be blocking
does it send that message
there's no point in doing what they are
Yeah I got no clue
no point in doing what
speaking into your mic 
As long as it works
Ig we can't record in discord.py?
"works" doesnt mean it's good either
record what
Honestly you don't need to do it through discord you can just make it output sound through your comphter
Like someone speaks and it listen to the audio
are you suggesting every stackoverflow question could be answered with "well just don't do that, it's pointless"
...?
It can be a sort of Spyware so i see why it doesn't really exist
Ye
That was the major concern when it was first discussed
there's a way to pipe audio directly into a discord voice channel through your mic?
@slate swan it says interaction failed
without using discord.py?
it is a discord thing, but discord.py hasnt implemented that yet, even py-cord has that (discord.py fork) and ig nextcord is also implementing that
almost a year
How do I not know this
I also don't know that
Oh makes sense
you'll have to switch libraries
Stackoverflow
did I ever say that? or even try to?
if there's a way to directly pipe the audio through your sound output and into the voice channel without discord.py I'd prefer to do that
Can anyone help me
there's no point, it will only be functional from the host computer
sorry it just sounded like your answer to my question was "why would you want to do that?"
https://paste.pythondiscord.com/libeyazudi
When i use this command
It says interaction failed
which seemed self explanatory
well, it's more of that you're confusing voice channel voice with computer voice
what do you mean
when you speak into your computer -> your computer listens to your voice and the bot will be blocked till it interprets what you spoke which will disconnect your bot from the gateway 90% of the times
when you speak in a voice channel -> the bot functions fine enough while waiting for your voice and you can interpret the audio easily
Q .How to send message through discord bot ??
I have 2 thred running
1st is discord
And 2nd is for something other
I want to send message through another thread how i would do that.
Help anyone pls!
I see. so there's no way to run the computer listener inside the bot's loop?
not really
Q .How to send message through discord bot ??
I have 2 thred running
1st is discord
And 2nd is for something other
I want to send message through another thread how i would do that.
It's working now!
stop spamming
wdym send a message through another thread
What will be the code to send from another thred
what-
R u a python programmer
I don't think
If you're using discord.py you shouldn't be messing with threads
Not for sending messages atleast
I have two thred one is for discord py
And in another one there is a websocket
I want to when I receive a message from websocket in 2 nd thred send that message to discord
I have two thred
In one I'm connecting two a websocket.
In 2nd I'm using discord py
When I'm receiving messages on websocket in thred one
I want send that message through discord py to discord channel.
I don't know how to do that
What should I do?
Why don't you connect to the ws in the first thread thougj
!d aiohttp.ClientSession.ws_connect
coroutine async-with ws_connect(url, *, method='GET', protocols=(), timeout=10.0, receive_timeout=None, auth=None, autoclose=True, autoping=True, heartbeat=None, origin=None, ...)```
Create a websocket connection. Returns a [`ClientWebSocketResponse`](https://aiohttp.readthedocs.io/en/stable/client_reference.html#aiohttp.ClientWebSocketResponse "aiohttp.ClientWebSocketResponse") object.
I don't know how to use it
yeah I'm not
little did I know I was in a python server the whole time
@slate swan help me out 🙂
which library you're using for websockets?
Websocket library
you shouldn't do that
why not?
doing stuff in on_ready is a bad practice
because
the event can be triggered multiple times
on startup and even while your code is running
you can make a task 
plz send me a piece of code to do this
plz
@slate swan
no spoon-feeding
at least tell me how to get a user using their ID
so that i can use user.mention or user.send
plz
@slate swan
!d discord.Client.get_user
get_user(id, /)```
Returns a user with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
thx so much @vocal snow
how and where have you defined client?
also, selfbotting is against discord's ToS
how could you tell it was a selfbot?
Explain selfbotting for me plz
Whats selfbit?
a discord bot that uses a non bot account
the bot=False in client.run
deprecated in dpy 2.0 thankfully
ah
i passed the params correct only in client.get_user(id=847054132649132032) but still,it returns None
1.7 actually
isn't id positional-only
means?
remove id=

i tried first itself
still it wasnt working
it gets the User obj from the cache
so you need to make sure the cache is ready before using it
Whats use of bot=False?
!d discord.Client.wait_until_ready
await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the client’s internal cache is all ready.
Warning
Calling this inside [`setup_hook()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.setup_hook "discord.Client.setup_hook") can lead to a deadlock.
so i have to use
client.get_user(847054132649132032)
specifies whether the token is a normal bot token or user token
no?
await wait_until_ready()
This function is a coroutine.
Waits until the client’s internal cache is all ready.
wat should i do then
client.get_user(847054132649132032)```
should i do this?
@vocal snow
someone plz help
im crying
its a method of client
^^ pls read
yes
then the ID is wrong/user doesnt share a guild with the bot/member intents disabled
how to enable member inents/share a guild with the bot
Guys i have a slash command i want that my bot join voice channel when the command i used
!d discord.VoiceChannel.connect
await connect(*, timeout=60.0, reconnect=True, cls=<class 'discord.voice_client.VoiceClient'>, self_deaf=False, self_mute=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.
This requires [`voice_states`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
Will it be
await interaction.response.connect
Anybody know how to fix this
What version of lib do you have
Traceback (most recent call last):
File "/home/runner/Cheeks-boost-hosting/venv/lib/python3.8/site-packages/discord/bot.py", line 992, in invoke_application_command
await ctx.command.invoke(ctx)
File "/home/runner/Cheeks-boost-hosting/venv/lib/python3.8/site-packages/discord/commands/core.py", line 358, in invoke
await injected(ctx)
File "/home/runner/Cheeks-boost-hosting/venv/lib/python3.8/site-packages/discord/commands/core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: FileNotFoundError: [Errno 2] No such file or directory: 'Data/1.txt'
How do i fix that?
interaction.response will return an InteractionResponse object
create that file ig?
Oh k
Create it where though lmao
os.mkdir(...)
1.7.3
Whats that lmao
working_dir/Data/1.txt
!d discord.Client.fetch_user try this (I think it should be supported in 1.7)
await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.
Note
This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.get_user "discord.Client.get_user") instead.
Changed in version 2.0: `user_id` parameter is now positional-only.
I want that it connect to channel to which user is connected
!d os.mkdir
os.mkdir(path, mode=0o777, *, dir_fd=None)```
Create a directory named *path* with numeric mode *mode*.
If the directory already exists, [`FileExistsError`](https://docs.python.org/3/library/exceptions.html#FileExistsError "FileExistsError") is raised. If a parent directory in the path does not exist, [`FileNotFoundError`](https://docs.python.org/3/library/exceptions.html#FileNotFoundError "FileNotFoundError") is raised.
On some systems, *mode* is ignored. Where it is used, the current umask value is first masked out. If bits other than the last 9 (i.e. the last 3 digits of the octal representation of the *mode*) are set, their meaning is platform-dependent. On some platforms, they are ignored and you should call [`chmod()`](https://docs.python.org/3/library/os.html#os.chmod "os.chmod") explicitly to set them.
This function can also support [paths relative to directory descriptors](https://docs.python.org/3/library/os.html#dir-fd).
It is also possible to create temporary directories; see the [`tempfile`](https://docs.python.org/3/library/tempfile.html#module-tempfile "tempfile: Generate temporary files and directories.") module’s [`tempfile.mkdtemp()`](https://docs.python.org/3/library/tempfile.html#tempfile.mkdtemp "tempfile.mkdtemp") function.
you able to show me while i screen share in a call
!d discord.Member.voice
property voice```
Returns the member’s current voice state.
discord.Member.voice.channel
that has a channel attr ^
hm
I think that would be VoiceState.channel I dunno how is the class called, might be VoiceProtocol
hm
!d discord.VoiceState.channel
The voice channel that the user is currently connected to. None if the user is not currently in a voice channel.
can someone tell me how to change the default help message when using this bot = commands.Bot(command_prefix="+")
Yes
There's a guide in pins, check them out
ok ty
bot.remove_command('help')
and then define a new help command i presume?
Bad method
No, look at pins
really, why so?
Cause you are going to have hell-like structure to do something that can be done easier with subclassing
How can I make commands syncing fast?
I've used it and it's never caused issues with me
I am not saying it won't work, it's just called bad practice
Yeah, I mean it's whatever
Depends
If you are coding for yourself it is indeed whatever but if others are going to see your code it's better to make it as readable as possible
yeah this is just a bot for a small server so its not gonna matter too much if it isnt perfect
you've been answered already, you cant
And anyways with subclass you don't have to do all that conversion
Hmmm
just make slash commands and dont make a help command 
await interaction.author.voice.channel.connect() i getting error in it
AttributeError?
Ye
You need to check if the member is connected to voice and none of attributes are None show the traceback please
im using pycord right now and i have a question regarding temporarily disabling buttons after interaction. lets say i have 3 buttons, attack block and skill. can i make it so skill is disabled for 2 interactions for example?
you'll have to write your own logic
It's interaction.user
For that I commonly do something like this
names_to_disable = (...)
for child in self.children:
if isinstance(child, discord.ui.Button) and child.label in names_to_disable:
child.disabled = True
await inter.message.edit(view=self)```
They are aliases afaik, not sure about dpy but in disnake that's for sure
for child in self.children:
if isinstance(child, discord.ui.Button) and child.label in names_to_disable:
do you mind telling me what you're doing here
self.children are the components of the view, isinstance checks if the child is a button and the second condition checks if button's label is in a sequence of names to disable
!d discord.ui.View.children
property children```
The list of children attached to this view.
with this it would completely disable it right?
Yeah and you can enable it back with setting disabled to False
ah ok, thank you but idk if it helps with the initial question i had about disabled for 2 interactions?
unless im missing something
That's up to you
i was gonna end up doing something scuffed like having some_var update when i click skill
Use some variables and implement your logic
yea
How to play audio in dpy voice?
import requests
import json
channelID = "your_id_goes_here"
botToken = "your_token_here"
baseURL = "https://discordapp.com/api/channels/{}/messages".format(channelID)
headers = { "Authorization":"Bot {}".format(botToken),
"User-Agent":"myBotThing (http://some.url, v0.1)",
"Content-Type":"application/json", }
message = "hello world"
POSTedJSON = json.dumps (
{
"content": message,
"tts": false,
"embeds": [{
"title": "Hello, Embed!",
"description": "This is an embedded message."
}]
})
r = requests.post(baseURL, headers = headers, data = POSTedJSON
This isn't working any idea how i can send a message using api
url has to be actual channel..?
!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.
url = 'https://discord.com/api/v8/channels/{channelID}/messages'
data = {"content": messagehere}
header = {"authorization": token}
r = requests.post(url, data=data, headers=header)
print(r.status_code)
@royal bone
the headers are wrongs
token = "your actual bot token"
headers = {
"Authorization": f"Bot {token}"
}```
you would also have to mention the Content-Type
oops my bad
I want to record all conversation of a channel 🙂
How could I save audio from a channel as mp3 using discord bot
which library?
which lib smh
How to use the bot to listen to the channel, and write everything that is said in it to the channel?
Same question
I want to make voice logs
Me too
After mp3 we can perform speech to text
And log it
Yes ... And if it is still possible to determine who said, then you can generally make protection from swear words
And throw it out of the channel
Ya i have a idea
After that we can train the nurel model with those text .
And make a bot who can talk with it self
I'm doing a project like this
And I want to make an encoder and decoder
What does it mean encoder and decoder
Hello, world! > !dlrew ,olloH
How to use the bot to listen to the channel, and write all conversation that said in it to the channel?
It isn't possible for bots to listen to users
You can't do that.
I thik it can be
Is there any other way
Like by using real account
That's self botting and it's against 
What does it mean
I didn't get it
It's against discord terms of services
it is 
Doing so will get you banned
how?
discord api does allow bots to receive voice through the gateway, some libraries like discord.js, py-cord already have those features implemented
Ya u r right
https://v12.discordjs.guide/voice/receiving-audio.html#basic-usage
I got this article
But I don't know Java script how i would use it
And my half bot is made in python
I have to do all code again in javascript
@slate swan
Can I make a api call between JavaScript and python
For getting audio it will call to JavaScript after getting audio it will be continue with python
I don't know what to do any idea
@slate swan sorry for ping but I've never done slash commands before is there like a gist somewhere, did you make one?
@slate swan if thats what ur looking for
yeah I found it
honestly looks way easier to use disnake for slash cmds
well yes, but if you get an understanding, it isn't hard
how does it look on disnake?
can you send an screenshot or something
google it ?
import disnake
from disnake.ext import commands
bot = commands.Bot(...)
@bot.slash_command()
async def uwu(inter: disnake.CommandInteraction) -> None:
...
bot.run()
both are almost identical
do you have to actually add the class to the code in d.py for slash cmds?
disnake doesnt have trees and leaves
nop
then?
phloem, xylem, epidermis, meristematic tissues, permanent tissues uwu 
you forgor something
all of them are not even in same category
thanks
ok
I know I just wrote whatever came to my mind
if you just want application commands dont use commands.Bot
👌
sarth what u doing here
import discord
from discord import app_commands
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
tree = app_commands.CommandTree(client)
?
!d disnake.ext.commands.InteractionBot
yeah
but you gotta sync too
class disnake.ext.commands.InteractionBot(*, sync_commands=True, sync_commands_debug=False, sync_commands_on_cog_unload=True, test_guilds=None, **options)```
Represents a discord bot for application commands only.
This class is a subclass of [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") and as a result anything that you can do with a [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") you can do with this bot.
This class also subclasses InteractionBotBase to provide the functionality to manage application commands.
no
yes
dpy better
explain
explain what it's personal preference
wym
sync the slash commands
how?
well personal preference and code usability are different things
read the gist smh
disnake
no
I;n lazy and its long
well
dont read it then
Okay
!d discord.app_commands.CommandTree.sync
await sync(*, guild=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Syncs the application commands to Discord.
This must be called for the application commands to show up.
okay!
basically bot.tree.sync()
Lmao
tbh, half the things aren't even required in the gist, it just seems long

it is long
ikr boring af
why u gys make gists
pause..
just make a website
ashley is literally jobless
we are in a channel where people use replit for bot hosting
😭
how do you expect them to host a proper website
true true

AWS >
I'm not 
no credit card
helping in #discord-bots and making tutorial gists is not a job ashley
are you like young?
women ☕
ima dude.
im just 17, and we are not allowed to have a cc until 18 here
what does this even mean
Where are you at?
I never said it is, never said it was

Sometimes it takes a real man to be best girl
no, it's never like that
india
nova will you help ashley make tutorial website
No
Where do you get this information from
ahh I see..
no thanks im good
A certain ape from Amazon gave me this info
makes sense
Wise one
How can you be so sure
bro
God says otherwise anyways off topic
@slate swan i noticed you didnt answer this
what can be the best default value placeholder for a parameter which takes an sequence
None ..., [] () or what
[] would be bad since its mutable
And how to see who entered the voice channel when? And how to create them
!d discord.on_voice_state_update use this event
discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceState "discord.VoiceState").
The following, but not limited to, examples illustrate when this event is called...
=None
Doesnt matter, all will require a check (or iteration check inside)
yeah i should go with None then, seems like the most reasonable option
Then typehint with sequence | None or Optional lol
This, guys, here, because of the creation of the command category, the bot stopped working for me
well you probably did something wrong
And the console is empty
How can I drag someone vai bot ?
Lol is this the way ?
read the last line
use discord developer website create a application and add it to your discord server then find a bot host website
alr
are you using terminal or Vs studio?
jus a question cuz im tryna look for which one i like using the best 
someone in here will lol
Ohh thanks sarth
dedicated to discord bots, with python.
i was finna need that lol.
ah yes makes sense
i don’t believe you can but don’t take advice from me lol
yeah that's a discord side issue
i’m jus in here too learn tbh
its looks so ugly now 
It does
async def on_ready():
for guild in bot.guilds:
for member in guild.members:
if "#0001" in member.discriminator:
print(member)``` it doesnt print them any idea why?
Member intents enabled?
yup
Also does member.discriminator include the #? I think it only has the 4 digits
oh yeah it only has 4 digits
how to make discrim command like dyno
!d discord.User.discriminator
The user’s discriminator. This is given when the username has conflicts.
https://media.discordapp.net/attachments/998524359444549722/1003260285890601000/mypkinfo.png
Guys i want that my bot reads the image and get me the orange numbers from it and the text
How can I do that?
Try using chrome/internet edge when uploading the pfp on the developer portal.
Hey, i have a question, is it possible with some library or something to use commands i the bots terminal, kinda like a Minecraft server or similair, for example, able to use a status command in the terminal of the bot?
A discord.py extension including useful tools for bot development and debugging.
!pypi pytesseract
Not like running bash commands in discord, but in the bot if that makes sense
Will it give the the text and number like this
HP 50
Something like an async input()
When i used it says
pyteseret is not installed or not in path idk how to do that on replit
Yes, if setup correctly, would need to make it find those things in the image
There is a library button in the sidebar menu, search for pytesseract
I installed using pip
Did you type out the library name correctly in your file?
Send the file in here
Ok
from PIL import Image
import pytesseract
print(pytesseract.image_to_string(Image.open('mypkinfo.png')))
Mmm
?
And that spits the library not found error?
It says
you can wrap the builtin input() function with asyncio.to_thread() for asynchronous input in your terminal, though its a bit janky if your bot also prints other stuff in the background
Aa cool, thanks a lot!
Tesseract doesmt seem to be supported by repl.it
Could host it on your own pc or search online for some image to text api
@cooldown(1, 2, BucketType.user) , what this command dose ?
woah, i usually go with aio.run_in_executor()
it makes the user be able to use the command one time every 2 seconds
Bucket.user ?
like its role ?
no, it means it applies to users
whats the error in terminal
message with attachments working
working this
this dont working
emebed without attachments doesnt work
why?
Hmmm
def check_if_it_is_me():
return True
@bot.check(check_if_it_is_me)
@bot.command()
async def hello(ctx):
print("hey"
anyone know how "check" works?
bcz that code giving me error
the error :
Exception has occurred: TypeError
check_if_it_is_me() takes 0 positional arguments but 1 was given
File main.py", line 27, in <module>
async def hello(ctx):
!d disnake.ext.commands.Bot.check
@check```
A decorator that adds a global check to the bot.
This is for text commands only, and doesn’t apply to application commands.
A global check is similar to a [`check()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.check "disnake.ext.commands.check") that is applied on a per command basis except it is run before any command checks have been verified and applies to every command the bot has.
Note
This function can either be a regular function or a coroutine.
Similar to a command [`check()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.check "disnake.ext.commands.check"), this takes a single parameter of type [`Context`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Context "disnake.ext.commands.Context") and can only raise exceptions inherited from [`CommandError`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CommandError "disnake.ext.commands.CommandError")...
Needs a ctx arg
Not for the command
Yes
thank u it works, i added ctx argo for both functions
Np
so after this error solved i wanted to check if the user is me :
def check_if_it_is_me(ctx):
return ctx.author.id == 702994033613471885 #my_id
@bot.check(check_if_it_is_me)
@bot.command()
async def hello(ctx):
print("hey")
the error is :
Exception has occurred: AttributeError
'Command' object has no attribute 'author'
File main.py", line 23, in check_if_it_is_me
return ctx.author.id == 702994033613471885 #my_id
File main.py", line 27, in <module>
async def hello(ctx):
@regal pulsar any idea how to fix it?
btw i tried to replace it with message.author.id and put the message as a discord.Message parametre and it gave me another error
Anybody know how i could use ivona text to speech in python !!
check is a bot method not a command decorator, read the description carefully
so either do
bot.check = my_check_function
''' or '''
@bot.event
async def check(ctx: commands.Context):
... #return a bool
@check```
A decorator that adds a global check to the bot.
This is for text commands only, and doesn’t apply to application commands.
A global check is similar to a [`check()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.check "disnake.ext.commands.check") that is applied on a per command basis except it is run before any command checks have been verified and applies to every command the bot has.
Note
This function can either be a regular function or a coroutine.
Similar to a command [`check()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.check "disnake.ext.commands.check"), this takes a single parameter of type [`Context`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Context "disnake.ext.commands.Context") and can only raise exceptions inherited from [`CommandError`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CommandError "disnake.ext.commands.CommandError")...
Heyy Ashley !
Where are you from?
@slate swan
UK 
but?
many people prefer using asyncio and pymongo. I would also suggest the same
can i know the main difference between there two , pymongo and motor ?
motor is nothing but asyncio and pymongo combined
ohh lol ok got it , thanks , btw can you shere any one example to pymongo with asyncio ? pls
so the code worked fine in case the checking is True
but if its False it raises an error :
discord.ext.commands.errors.CheckFailure: The global check functions for command hello failed.
so i tried this but its not working :
@bot.listen()
async def check_if_it_is_me(ctx):
return ctx.author.id == 11815 #random_number to give me False
try :
@bot.check(check_if_it_is_me)
except discord.ext.commands.errors.CheckFailure :
pass
else :
@bot.command()
async def hello(ctx,):
print("hey")
what....
is that
you dont need py try : @bot.check(check_if_it_is_me) except discord.ext.commands.errors.CheckFailure : pass else :
then what should i do?
just delete that bit
and do async def check not async def check_if_it...
yes it will
hello. How do I connect my discord.py bot to a firebase database? if it helps i just need to read data, no writing. Thanks
you cant avoid it but you'll have to simply handle it in the error handler event
i heard of the "error handler " thing but i ve never used it before can u give me an example of how to use it?
@bot.listen("on_command_error")
async def error_handler(ctx: commands.Context, error: commands.CommandError) -> None:
if isinstance(error, commands.CheckFailure):
print(f"check failed for command {ctx.command.name}")
basically like a commands missing permission error
thank you guys for help
@bot.command(
name="dm"
)
async def dm(ctx, user:discord.User, *, message=None):
DM = await user.create_dm()
await DM.send(message)```
how do I make it so that 'user' can be a mention ( @glossy flame ), an ID (675798876858482731), or just the user and tag (UltraSonicSpeed#5985)?
Try and except
i used len(client.guilds) to get the guilds the bot is in but it say's 0
Is your bot in any guilds?
User.mention
well I know you can do user.mention and user.id but where do I put it
14
Wdym where
you know user:discord.User
Yeah
discord.User is just the name and tag, right?
so how do I put mention and ID there too
Come back if it returns an error
ok
@scarlet pond
Can I see that snippet of code
14 - 15
Code?
it is here
infohelpe.add_field(name=":guild: Servers", value=f"{len(client.guilds)}", inline=False)
now it doesn't even work with anything
Uh
yuh i have this embed variable outside a command
Just do client.guilds and see the output
without len?
Yeah
Yeah but it's for debugging
User.mention
wha-
I'm not sure why
IS THIS WHAT U R TRYING TO SAY
it works for my guilds command
Oh wait
why cap spam
No
imagine using replit 😔
Do user:discord.User
I did that before
isn't it discord.Member?
you are misunderstanding the problem
And then I think it's DM = await user.id.create_dm()
listen
Oh yeah
the problem is
Do that
Can I see the full command
@scarlet pond
for the embed?
Yeah
you can use a converter
i don't have the embed in a command
it's been a while since I used them so i'll have to check the docs rq
Oh
What is it in
When does it output
this
When does it trigger*
on button interaction
Can I see that part
@discord.ui.button(emoji=":icons_home:",style=discord.ButtonStyle.grey)
async def blurple1_button234(self,interaction: Interaction, button: Button):
button.disabled = False
await interaction.response.edit_message(embed=mianhelp)
so .format() is what I need to use
no
read the content of the photo
look at line 2 of the code part
Does client.guilds require ctx
async def joined(ctx, *, member: discord.Member):
You need the discord.Member part
uh no?
Sorry it's been a while for me
you can either do discord.Member or commands.MemberConverter
Have you checked the docs because ur code seems fine
imean i did use len(client.guilds) in bot's status once and it worked fine
is discord.Member supposed to automatically be either ID, mention or just user and tag? because ID or just user and tag dont seem to work
can I see that code
How to make the buttons that were attached to the embed work after restarting the bot? discord_components
how do i define Client?
im trying to get all text channels and the code i found for it uses Client, and when i try it says i need to define it
dont use discord_components and there's no way
🤔
is it discord.Client?
yes, see their examples in the github repo
Client = discord.Client ?
tested and got this
TypeError: 'property' object is not iterable
text_channel_list = []
for server in discord.Client.guilds:
for channel in server.channels:
if str(channel.type) == 'text':
text_channel_list.append(channel)```
await client.change_presence( activity= discord.Streaming( platform = 'YouTube' ,name= 'PLAYGROUND' , game='PLAYGROUND GAME' ,url= 'LINK'))```
why twitch ?
uh
I'm not sure how to help exactly
sorry :(
??? 🤔
@slate swan any help 😔
what's the issue? 
ah, when are you making this embed?
...
class discord.Streaming(*, name, url, **extra)```
A slimmed down version of [`Activity`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Activity "discord.Activity") that represents a Discord streaming status.
This is typically displayed via **Streaming** on the official Discord client.
x == y Checks if two streams are equal.
x != y Checks if two streams are not equal.
hash(x) Returns the stream’s hash.
str(x) Returns the stream’s name.
because discord only has twitch support
is there a way to get all the text channels of one server(the only one the bot is in)
!d discord.Guild.text_channels
property text_channels```
A list of text channels that belongs to this guild.
This is sorted by the position and are in UI order from top to bottom.
can i get it in list form?
!
yes text_channels returns a list of TextChannel objects
...
well when i print it i get this
<property object at 0x000001E61756FF90>
wait is it an function
nope
its clearly not a list
neither a function
wdym
how do i get the list
in that case
get a Guild object and use the text_channels property on it smh
!d discord.Client.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
code example
It's hard when you have to explain OOP 
whats a guild
a server
I wont, let them cope
their mistake not my headache 
Can you make a !oop tag
You can
Make a PR to the python bot repo
meh
too lazy plus no time
discord.Client.get_guild("server id").text_channels #what now
help?
create a Client object first, dont use the class itself
h o w
unless it's a staticmethod that is
client = discord.Client()
yes
client.get_guild(97...).text_channels
why .get.get_guild
please explain
mistake
right and the server id should be an integer
ik
and now?
its still an property
You know what they say. Once a property, always a property.
I'd recommend reading up on OOP. Wi help you loads
reason why I didnt give you the "example code"
ok thanks
i got an list now
Ashley back me up #community-meta message
why py await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching , name = 'pp' ,url = 'link' , state = 'ingame', details = "details shit" , large_image_url = 'image.png' )
this only showing watching
i want url , state and other thigs as wll
well
@slate swan big thanks for the help again. i see you dident like my stupidity but thanks for helping me. this also taught me a bit more about classes.
How do I make slash commands work with normal commands with a prefix too?
how do i get a bot to mention a user
typ @ username#0000, i belive thats all
dont include the space between @ and u
oh right the id makes sense
doesnt work :/
!d discord.Member.mention
property mention```
Returns a string that allows you to mention the member.
@slate swan
@west niche
i just guessed
;-; okie

hmm
bro
I wasnt in the mood to deal with that stuff again
sorry
i realised
is there an message contains tag?
!d discord.Message.content
The actual contents of the message. If Intents.message_content is not enabled this will always be an empty string unless the bot is mentioned or the message is a direct message.
you dont need to apologize!!
but you should feel bad about it.
Basically.
Do know that in is quite a broad spectrum.
So if "hi" in "Wow, that panda is high in the tree." It will also trigger.
oof
👋 hey. what's wrong with pandas here?
print("on" in replied_message)
True
Well not if hi is on the start or end of a message.
welp
Just str.split
who cares im using it to censor the n-word so hey
I recommend fuzzy matching then.
isnt there automod in discord?
There is pretty sick :3
cant bother + i like programming
lol
You need to program it tough... lol
its like 6 lines of code
Just look into the automod it's good.
and it makes a funny moment instead of just muting someone
im pretty sure automod has that
the action if the word filter is triggered
It's a rule you can edit.
But like I said I recommend checking it out.
im making it so my bot will say "AYOOOOO WT# (username)"
and tag me so i can come see what happend
why am i dumb
then why not code smth like this? lmao @slate swan
okay now it worked
Not entirely sure if it will catch all the words tough since if you don message.content you can fuzzy match the string and with automod it needs to be 100% as far as i know.
is there an unrelated / memes channel
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
doesnt auto mod have like variants and a good thing about it is that the words get caught before dispatched to the guild iirc
thanks
that off topic channel sucks welp
Don't know about the variants, before it gets send is true. Also see it auto catches edits as well.
yeah, cool
also quick check higher() converts a message to higher case like lower() right?
you mean upper?
!d str.upper
ah thanks ok
str.upper()```
Return a copy of the string with all the cased characters [4](https://docs.python.org/3/library/stdtypes.html#id15) converted to uppercase. Note that `s.upper().isupper()` might be `False` if `s` contains uncased characters or if the Unicode category of the resulting character(s) is not “Lu” (Letter, uppercase), but e.g. “Lt” (Letter, titlecase).
The uppercasing algorithm used is described in section 3.13 of the Unicode Standard.
I mean banning domains with it from scam sites is golden.
yeah, especially the close ones to discord
channel.send(" AYOOOOOOO WTF "+user+" <@my id> COME LOOK AT THIS!")
!f-strings
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.
no need for str concatenation
user + "..." would error because user would still be a User | Member instance, you need to get a string representation of it
!e ```py
123 + "foo"
@pliant gulch :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | TypeError: unsupported operand type(s) for +: 'int' and 'str'
on this, cant discord take legal actions over fake domains?
can two scripts run the same bot?
javascript enters the light
Depends on what the site is doing, if it is scamming people sure, but if it isn't and it's just doing it's own thing and doesn't look/relate to Discord then no, not really.
mhm cool
that was also in the video i sent you😭
It could but why would you even need that.
I know
thats discords public domain bro
😭
the real domain
lol
lovely😍
Doesnt need to be phising persay, as long as the website is fraudulent, including domain names such as d1scord.com or whatever, just contact CSIRTs or CERTs and they will take it down since that isn't allowed
Fraudulent could be making people believe its a real discord website instead of a fake one
"We do not mean hate to the company or it's employees. - This website is classified a parody under fair use."
Parodies are covered under copyright so shitcord is fine
Robin, no offence but.....I always think that your humour is no more than a 12-year-old 💀 "no offence"
the heck is CSIRTs and CERTs? and cant you contact like maybe the supplier of the domain or vps?
Robin has humor?
I agree, my humour has devolved over the years. It used to be good but not anymore haha
feels like a sad story
Kind of like internet regulators
You could contact the domain registrar or the VPS provider but that's a lot more difficult
They don't always respond, unless registered together with ICANN or something
I cannot remember
yeah, dont most vps have like water marks or something
like displaying who provides the server
is it time for the andy copypasta
oh no.........
Hey, I currently have a pycord bot and it sends a message with a file in it, but I want to edit the message such that the file is removed. I tried doing file = None, but it didn't work. Any ideas?

