#discord-bots

1 messages · Page 12 of 1

sick birch
#

Turn both of them on

#

though i'm not sure if this is the error

#

The ban's probably up

left raptor
#

yep both of those are on

sick birch
#

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

slate swan
sick birch
slate swan
#

@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

sick birch
left raptor
#

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'```

slate swan
sick birch
#

It will, until it starts growing

slate swan
royal bone
#

How i can send message to channel from another thred

slate swan
royal bone
#

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.

left raptor
#

all this code was frankensteined together from stackoverflow posts

#

I don't know what I'm doing

scarlet pond
royal bone
#

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.

scarlet pond
#

I think you are using client

left raptor
scarlet pond
scarlet pond
slate swan
#

Does anybody know a good site i can host my bot on?

scarlet pond
#

you need some other code in the top btw

left raptor
#

oh this?

load_dotenv('discord_bot.env')
TOKEN = os.getenv('DISCORD_TOKEN')
bot = commands.Bot(command_prefix="!", intents=intents)


client = discord.Client()```
slate swan
#

Does anybody know a good site i can host my bot on? please answer

scarlet pond
#

$7 a month

scarlet pond
slate swan
scarlet pond
royal bone
slate swan
scarlet pond
#

oh

#

what are you hosting on rn

royal bone
slate swan
scarlet pond
royal bone
left raptor
scarlet pond
vagrant brook
left raptor
scarlet pond
#

I guess thats what threads are for

slate swan
scarlet pond
scarlet pond
vagrant brook
#

you have a bot and client in your code and you only need one of those two

vagrant brook
#

danny came back

scarlet pond
#

I thought there was something about keeping it maintained

#

oh

slate swan
scarlet pond
#

dang I need to keep up with the news

scarlet pond
vagrant brook
#

no

scarlet pond
#

thank god

vagrant brook
left raptor
#

and how does having bot and client cause that?

scarlet pond
#

but you also can't use both

vagrant brook
#

because you need to start from something simple to learn programming, not copy code from the internet and expect it to just work

left raptor
scarlet pond
scarlet pond
robust fulcrum
#

Guys how can I remove a slash comamnd for servers? Of my bot?

scarlet pond
#

a bot you created?

left raptor
#

cause then this throws an error @client.event

scarlet pond
#

then you replace client with bot

left raptor
#

bot.event?

scarlet pond
#

yeah

slate swan
robust fulcrum
left raptor
#

ok I changed it to @bot.event and now the on_ready function never runs

slate swan
scarlet pond
#

I can't really help without it

left raptor
#
@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)```
slate swan
#

DON'T DO SHIT IN ON_READY

scarlet pond
#

yeah its gonna mess things up

left raptor
scarlet pond
#

make a command to run that

slate swan
#

that will never run 9 outta 10 times

robust fulcrum
left raptor
#

or can only users call commands

slate swan
left raptor
scarlet pond
#

I'm not familiar with what people do now :(

#

I thought it was just commands

robust fulcrum
slate swan
slate swan
robust fulcrum
#

Ok

left raptor
#

wait but this isn't something I can call is it

slate swan
#

?

left raptor
#

it just runs automatically every ten minutes?

slate swan
#

yeah

scarlet pond
slate swan
#

once you start it

left raptor
scarlet pond
#
@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)
left raptor
#

you can't just call them from script

scarlet pond
#

eventually it will stop running without hosting I guess

left raptor
#

my goal here is to have a script I wrote that listens to my microphone input and detects keywords

slate swan
left raptor
#

and when it detects a certain keyword, I want an audio clip to play in the voice channel

scarlet pond
slate swan
left raptor
slate swan
#

discord does

left raptor
#

I said my mic

scarlet pond
#

wait does djs have voice receive

slate swan
#

yep

left raptor
#

and I already wrote that script

scarlet pond
#

oh dang

left raptor
slate swan
scarlet pond
#

oh

#

uh

slate swan
#

anyways you can use a task

left raptor
# slate swan oh cool ~~can I steal it~~

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())```
scarlet pond
#

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

scarlet pond
#

istg I watched a tutorial like 2 years ago and the code was just like that

slate swan
#

that code makes me wanna shit in my pants UniSips

robust fulcrum
slate swan
robust fulcrum
#

Hmmm

scarlet pond
#

replit mobile 0-0

left raptor
scarlet pond
#

understandable

robust fulcrum
scarlet pond
#

I think that means delete that line of code

robust fulcrum
#

Hmmm

left raptor
robust fulcrum
#

Ye now it worked

left raptor
#

instead of running at periodic intervals?

scarlet pond
left raptor
scarlet pond
#

as far as I know, no

#

you can read the docs or consult stackoverflow tho

left raptor
#

like just

if condition happens:
    play_audio_in_voice_channel()
robust fulcrum
slate swan
#

code

robust fulcrum
#

Me?

scarlet pond
slate swan
robust fulcrum
#

Ok

scarlet pond
#

and the task can be set to run to the minimum (rate limit time)

left raptor
#

but then wouldn't there be significant lag time in between when my script calls the function and when it actually happens?

scarlet pond
#

yeah but thats kinda the only way

scarlet pond
#

depends

scarlet pond
slate swan
robust fulcrum
#

What?

slate swan
#

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())

left raptor
#

you're sure there's no way to call commands from script?

#

that seems ridiculous that you couldn't do that

slate swan
robust fulcrum
left raptor
# slate swan Wdym?

I just want a function that I can call normally, not like an async blocking function or whatever

slate swan
left raptor
#

that way when my other script detects a certain word, it can play an audio clip

slate swan
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

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").
slate swan
#

you can specify nothing in the deco

#

and it'll loop constantly

slate swan
#

but that's a bad practice in your case

left raptor
left raptor
#

it'll all be done from script

slate swan
#

what's your goal here

left raptor
#

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

slate swan
#

Ahh I don't know of any way that wouldn't be blocking..

#

@slate swan got any idea?

#

it will be blocking

slate swan
#

there's no point in doing what they are

#

Yeah I got no clue

left raptor
slate swan
scarlet pond
robust fulcrum
slate swan
slate swan
scarlet pond
#

Honestly you don't need to do it through discord you can just make it output sound through your comphter

robust fulcrum
#

Like someone speaks and it listen to the audio

left raptor
slate swan
#

...?

scarlet pond
robust fulcrum
#

Ye

scarlet pond
#

That was the major concern when it was first discussed

left raptor
robust fulcrum
left raptor
slate swan
scarlet pond
#

Dang

#

How long has it been around

slate swan
#

almost a year

scarlet pond
#

How do I not know this

robust fulcrum
#

I also don't know that

scarlet pond
#

Oh makes sense

robust fulcrum
#

I should use that :)

#

And make a Google assistant in discord lol

slate swan
#

you'll have to switch libraries

scarlet pond
slate swan
left raptor
#

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

robust fulcrum
#

Can anyone help me

slate swan
left raptor
robust fulcrum
left raptor
#

which seemed self explanatory

slate swan
slate swan
#

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

royal bone
#

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.

left raptor
royal bone
#

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.

robust fulcrum
scarlet pond
royal bone
scarlet pond
#

what-

royal bone
vocal snow
#

Not for sending messages atleast

royal bone
#

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?

vocal snow
#

Why don't you connect to the ws in the first thread thougj

#

!d aiohttp.ClientSession.ws_connect

unkempt canyonBOT
#
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.
royal bone
slate swan
#

little did I know I was in a python server the whole time

slate swan
#

which library you're using for websockets?

royal bone
#

Websocket library

paper vector
#

i want my bot to DM a person on_ready.How can i achive this

#

plz help

#

me

slate swan
paper vector
#

why not?

slate swan
#

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

paper vector
#

then plz tell me how i can DM a person using theit id

slate swan
paper vector
#

plz

#

@slate swan

slate swan
#

no spoon-feeding

paper vector
#

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

vocal snow
#

!d discord.Client.get_user

unkempt canyonBOT
#

get_user(id, /)```
Returns a user with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
paper vector
#

thx so much @vocal snow

cerulean solstice
#

helps pls

vocal snow
#

also, selfbotting is against discord's ToS

cerulean solstice
#

ohk i did not know

#

guess i will delete

narrow belfry
slate swan
robust fulcrum
#

Whats selfbit?

narrow belfry
#

a discord bot that uses a non bot account

vocal snow
#

deprecated in dpy 2.0 thankfully

narrow belfry
#

ah

paper vector
#

i passed the params correct only in client.get_user(id=847054132649132032) but still,it returns None

narrow belfry
#

1.7 actually

paper vector
#

means?

narrow belfry
#

remove id=

narrow belfry
paper vector
#

i tried first itself
still it wasnt working

vocal snow
#

it gets the User obj from the cache

#

so you need to make sure the cache is ready before using it

robust fulcrum
vocal snow
#

!d discord.Client.wait_until_ready

unkempt canyonBOT
#

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.
paper vector
#

so i have to use

      client.get_user(847054132649132032)
vocal snow
vocal snow
#

await wait_until_ready()

This function is a coroutine.

Waits until the client’s internal cache is all ready.

paper vector
#

wat should i do then

#
 client.get_user(847054132649132032)```
#

should i do this?

#

@vocal snow

#

someone plz help

#

im crying

vocal snow
#

its a method of client

vocal snow
paper vector
#
await client.wait_until_ready()
client.get_user(847054132649132032)```
#

correct?

vocal snow
#

yes

paper vector
#

thx so much

#

still returning None

vocal snow
#

then the ID is wrong/user doesnt share a guild with the bot/member intents disabled

paper vector
#

how to enable member inents/share a guild with the bot

robust fulcrum
#

Guys i have a slash command i want that my bot join voice channel when the command i used

paper vector
#

@vocal snow

#

plz hrlp

unkempt canyonBOT
#

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").
robust fulcrum
slate swan
#

Anybody know how to fix this

vale wing
slate swan
#

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?

slate swan
vocal snow
slate swan
vale wing
paper vector
slate swan
vocal snow
vale wing
unkempt canyonBOT
#

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.
robust fulcrum
vale wing
unkempt canyonBOT
#

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.
slate swan
vocal snow
unkempt canyonBOT
slate swan
vocal snow
slate swan
#

hm

vale wing
slate swan
#

hm

vale wing
#

!d discord.VoiceState.channel

unkempt canyonBOT
#

The voice channel that the user is currently connected to. None if the user is not currently in a voice channel.

grizzled badger
#

can someone tell me how to change the default help message when using this bot = commands.Bot(command_prefix="+")

vale wing
#

Yes

vale wing
grizzled badger
#

ok ty

grizzled badger
vale wing
vale wing
slate swan
vale wing
#

Cause you are going to have hell-like structure to do something that can be done easier with subclassing

robust fulcrum
#

How can I make commands syncing fast?

slate swan
#

I've used it and it's never caused issues with me

vale wing
slate swan
vale wing
#

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

grizzled badger
#

yeah this is just a bot for a small server so its not gonna matter too much if it isnt perfect

slate swan
vale wing
#

And anyways with subclass you don't have to do all that conversion

robust fulcrum
slate swan
#

just make slash commands and dont make a help command pepe_exit

robust fulcrum
vale wing
#

AttributeError?

robust fulcrum
vale wing
#

You need to check if the member is connected to voice and none of attributes are None show the traceback please

left idol
#

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?

slate swan
#

you'll have to write your own logic

vale wing
#

Where from do you want to disable them from

#

View subclass or a message/command?

left idol
#

wym

#

i think view subclass

vale wing
#

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)```
vale wing
left idol
#
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

vale wing
#

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

unkempt canyonBOT
left idol
#

with this it would completely disable it right?

vale wing
#

Yeah and you can enable it back with setting disabled to False

left idol
#

ah ok, thank you but idk if it helps with the initial question i had about disabled for 2 interactions?

#

unless im missing something

vale wing
#

That's up to you

left idol
#

i was gonna end up doing something scuffed like having some_var update when i click skill

vale wing
#

Use some variables and implement your logic

left idol
#

yea

robust fulcrum
#

How to play audio in dpy voice?

royal bone
#
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
royal bone
slate swan
unkempt canyonBOT
#

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.

slate swan
#
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

royal bone
#

I want to record all conversation of a channel 🙂
How could I save audio from a channel as mp3 using discord bot

slate swan
#

which library?

royal bone
#

I want to receive channel audio and save as mp3

#

Any idea

slate swan
#

which lib smh

vale chasm
#

How to use the bot to listen to the channel, and write everything that is said in it to the channel?

vale chasm
#

I want to make voice logs

royal bone
#

After mp3 we can perform speech to text
And log it

vale chasm
#

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

royal bone
#

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

vale chasm
#

And I want to make an encoder and decoder

royal bone
vale chasm
#

Hello, world! > !dlrew ,olloH

royal bone
#

How to use the bot to listen to the channel, and write all conversation that said in it to the channel?

tough lance
#

You can't do that.

royal bone
tough lance
royal bone
tough lance
#

It's against discord terms of services

slate swan
tough lance
#

Doing so will get you banned

tough lance
slate swan
# tough lance *how?*

discord api does allow bots to receive voice through the gateway, some libraries like discord.js, py-cord already have those features implemented

royal bone
#

But I don't know Java script how i would use it

royal bone
#

@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
#

@slate swan sorry for ping but I've never done slash commands before is there like a gist somewhere, did you make one?

swift pumice
#

@slate swan if thats what ur looking for

slate swan
#

honestly looks way easier to use disnake for slash cmds

slate swan
swift pumice
#

can you send an screenshot or something

slate swan
#

google it ?

slate swan
shrewd apex
#

both are almost identical

slate swan
#

yep

#

no

slate swan
#

loooli disnake doesnt have trees and leaves

slate swan
slate swan
slate swan
#

but you remain in my heart, so no

shrewd apex
#

all of them are not even in same category

slate swan
#

I know I just wrote whatever came to my mind

slate swan
shrewd apex
#

👌

shrewd apex
slate swan
#
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

unkempt canyonBOT
#

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.
slate swan
#

I don't get the tree shit

#

make an event for that or overwrite

#

this better than dpy lol

shrewd apex
#

no

slate swan
#

yes

shrewd apex
#

dpy better

slate swan
#

explain

shrewd apex
#

explain what it's personal preference

slate swan
slate swan
slate swan
vocal snow
#

better than what tho

slate swan
#

well personal preference and code usability are different things

slate swan
slate swan
slate swan
#

I;n lazy and its long

#

well

#

dont read it then

#

Okay

slate swan
unkempt canyonBOT
#

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.
slate swan
#

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

vocal snow
#

why u gys make gists

slate swan
#

pause..

vocal snow
#

just make a website

slate swan
#

no one has time for that

#

and hosting

vocal snow
slate swan
slate swan
#

how do you expect them to host a proper website

vocal snow
#

true true

slate swan
slate swan
slate swan
vocal snow
slate swan
grim oar
#

women ☕

slate swan
slate swan
vocal snow
slate swan
slate swan
grim oar
slate swan
slate swan
vocal snow
grim oar
#

No

slate swan
#

Where do you get this information from

slate swan
slate swan
grim oar
slate swan
grim oar
#

Wise one

slate swan
#

Apes don't talk.

#

humans are apes

grim oar
#

How can you be so sure

slate swan
slate swan
vocal snow
slate swan
#

thi what can be the best default value placeholder for a parameter which takes an sequence
None ..., [] () or what

#

[] would be bad since its mutable

vale chasm
#

And how to see who entered the voice channel when? And how to create them

slate swan
unkempt canyonBOT
#

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...
grim oar
slate swan
#

yeah i should go with None then, seems like the most reasonable option

grim oar
#

Then typehint with sequence | None or Optional lol

vale chasm
#

This, guys, here, because of the creation of the command category, the bot stopped working for me

slate swan
#

well you probably did something wrong

vale chasm
#

And the console is empty

limber bison
#

How can I drag someone vai bot ?

limber bison
heavy folio
#

read the last line

odd mango
#

imagine

#

just so you know self bots are against discord ToS

#

okay then fix your token

slate swan
#

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 py_guido

royal bone
#

Anybody who know how to use discord.js

#

??

slate swan
#

someone in here will lol

royal bone
#

?

slate swan
#

Bcuz this channel is dedicated too discord bots lol

royal bone
slate swan
slate swan
slate swan
cobalt jacinth
#

how to change embed width? discord changed something and embed so stretched now.

slate swan
#

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

cobalt jacinth
#

its looks so ugly now FrogeSadPat

slate swan
#

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?
shrewd kraken
#

need help

#

why is my bot's pfp this

#

and how do i make it not that

vocal snow
slate swan
vocal snow
#

Also does member.discriminator include the #? I think it only has the 4 digits

shrewd kraken
#

oh yeah it only has 4 digits

slate swan
#

how to make discrim command like dyno

heavy folio
#

!d discord.User.discriminator

unkempt canyonBOT
robust fulcrum
modest nymph
spring quartz
#

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?

shrewd apex
#

use jishaku

#

!pypi jishaku

unkempt canyonBOT
unkempt canyonBOT
spring quartz
robust fulcrum
spring quartz
robust fulcrum
spring quartz
spring quartz
robust fulcrum
spring quartz
#

Did you type out the library name correctly in your file?

robust fulcrum
#

Ye

#

I used their example

spring quartz
#

Send the file in here

robust fulcrum
#

Ok

robust fulcrum
spring quartz
#

Mmm

robust fulcrum
#

?

spring quartz
#

And that spits the library not found error?

robust fulcrum
hushed galleon
spring quartz
#

Aa cool, thanks a lot!

spring quartz
robust fulcrum
#

Hm

#

What to do now

spring quartz
#

Could host it on your own pc or search online for some image to text api

limber bison
#

@cooldown(1, 2, BucketType.user) , what this command dose ?

iron sorrel
iron sorrel
limber bison
#

like its role ?

iron sorrel
#

no, it means it applies to users

limber bison
#

ohk k ,

slate swan
#

please help

#

Why this doesn't work?

limber bison
slate swan
#

message with attachments working

#

working this

#

this dont working

#

emebed without attachments doesnt work

#

why?

limber bison
#

list ?/

silver reef
#
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):
regal pulsar
unkempt canyonBOT
#

@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")...
regal pulsar
#

Needs a ctx arg

silver reef
#

wait u mean for the check func?

regal pulsar
#

Not for the command

regal pulsar
silver reef
#

thank u it works, i added ctx argo for both functions

regal pulsar
#

Np

silver reef
#

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

royal bone
#

Anybody know how i could use ivona text to speech in python !!

slate swan
regal pulsar
#

I see

#

But

#

!d disnake.ext.commands.Bot.check

unkempt canyonBOT
#

@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")...
royal bone
#

Heyy Ashley !
Where are you from?

limber bison
#

which is batter pymongo or motor ?

#

for bot

#

and why ?

royal bone
slate swan
slate swan
maiden fable
limber bison
maiden fable
#

motor is nothing but asyncio and pymongo combined

limber bison
#

ohh lol ok got it , thanks , btw can you shere any one example to pymongo with asyncio ? pls

silver reef
# slate swan `check` is a bot method not a command decorator, read the description carefully ...

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")

slate swan
#

what....

#

is that

#

you dont need py try : @bot.check(check_if_it_is_me) except discord.ext.commands.errors.CheckFailure : pass else :

silver reef
#

then what should i do?

slate swan
#

just delete that bit

silver reef
#

when its False

#

it raises an error

slate swan
#

and do async def check not async def check_if_it...

slate swan
silver reef
#

i want to avoid that error

#

so any solution?

waxen ruin
#

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

slate swan
silver reef
slate swan
prime sleet
silver reef
#

thank you guys for help

glossy flame
#
@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)?
scarlet pond
slate swan
#

i used len(client.guilds) to get the guilds the bot is in but it say's 0

scarlet pond
#

Is your bot in any guilds?

glossy flame
slate swan
glossy flame
scarlet pond
#

Yeah

glossy flame
#

discord.User is just the name and tag, right?

scarlet pond
#

Yeah

#

And then add .mention I believe

glossy flame
#

so how do I put mention and ID there too

scarlet pond
#

Come back if it returns an error

glossy flame
#

ok

slate swan
scarlet pond
slate swan
#

14 - 15

scarlet pond
#

Code?

slate swan
# scarlet pond Code?
infohelpe.add_field(name=":guild: Servers", value=f"{len(client.guilds)}", inline=False)
glossy flame
slate swan
#

yuh i have this embed variable outside a command

scarlet pond
#

Just do client.guilds and see the output

slate swan
#

without len?

scarlet pond
#

Yeah

slate swan
#

i dont think the input would be in integer

#

but lemme check

scarlet pond
#

Yeah but it's for debugging

scarlet pond
slate swan
scarlet pond
#

So empty list

slate swan
#

wha-

scarlet pond
#

I'm not sure why

glossy flame
slate swan
#

it works for my guilds command

scarlet pond
slate swan
scarlet pond
#

No

slate swan
#

imagine using replit 😔

scarlet pond
#

Do user:discord.User

glossy flame
#

I did that before

slate swan
#

isn't it discord.Member?

glossy flame
#

you are misunderstanding the problem

scarlet pond
#

And then I think it's DM = await user.id.create_dm()

glossy flame
#

listen

scarlet pond
glossy flame
#

the problem is

scarlet pond
#

Do that

scarlet pond
slate swan
slate swan
scarlet pond
#

Yeah

slate swan
#

i don't have the embed in a command

gilded gust
#

it's been a while since I used them so i'll have to check the docs rq

scarlet pond
#

Oh

scarlet pond
#

What is it in

slate swan
scarlet pond
#

When does it output

gilded gust
#

@glossy flame

slate swan
scarlet pond
#

When does it trigger*

slate swan
#

on button interaction

scarlet pond
#

Can I see that part

slate swan
#
    @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)
glossy flame
gilded gust
#

read the content of the photo

#

look at line 2 of the code part

scarlet pond
#

Does client.guilds require ctx

gilded gust
#
async def joined(ctx, *, member: discord.Member):

You need the discord.Member part

slate swan
scarlet pond
#

Sorry it's been a while for me

gilded gust
scarlet pond
slate swan
#

imean i did use len(client.guilds) in bot's status once and it worked fine

glossy flame
proud apex
#

How to make the buttons that were attached to the embed work after restarting the bot? discord_components

slate swan
#

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

slate swan
proud apex
#

🤔

slate swan
scarlet pond
#

Client = discord.Client ?

slate swan
#
text_channel_list = []
    for server in discord.Client.guilds:
        for channel in server.channels:
            if str(channel.type) == 'text':
                text_channel_list.append(channel)```
limber bison
#
await client.change_presence( activity= discord.Streaming( platform = 'YouTube' ,name= 'PLAYGROUND' , game='PLAYGROUND GAME'  ,url= 'LINK'))```
#

why twitch ?

scarlet pond
#

I'm not sure how to help exactly

#

sorry :(

slate swan
#

ill go and take a help channel

#

thanks for your effort

slate swan
#

ah, when are you making this embed?

slate swan
#

?

#

!d discord.Streaming

unkempt canyonBOT
#

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.
slate swan
#

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)

slate swan
unkempt canyonBOT
#

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.
slate swan
#

can i get it in list form?

slate swan
slate swan
#

...

#

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

slate swan
#

how do i get the list

#

in that case

slate swan
#

!d discord.Client.get_guild

unkempt canyonBOT
#

get_guild(id, /)```
Returns a guild with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
slate swan
#

code example

vocal snow
slate swan
#

whats a guild

vocal snow
#

a server

slate swan
#

their mistake not my headache shrug

vocal snow
#

Can you make a !oop tag

slate swan
#

you cant create custom tags in this server lol

#

plus a single embed wont help

vocal snow
#

Make a PR to the python bot repo

slate swan
#

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

slate swan
slate swan
#

please explain

#

mistake

#

right and the server id should be an integer

#

ik

#

and now?

#

its still an property

vocal snow
#

You know what they say. Once a property, always a property.

slate swan
#

im new to python

#

imma test the code

vocal snow
#

I'd recommend reading up on OOP. Wi help you loads

slate swan
#

ok thanks

#

i got an list now

vocal snow
limber bison
#

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
#

@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.

elfin moon
#

How do I make slash commands work with normal commands with a prefix too?

grizzled badger
#

how do i get a bot to mention a user

slate swan
#

dont include the space between @ and u

grizzled badger
#

oh right the id makes sense

grizzled badger
paper sluice
#

!d discord.Member.mention

unkempt canyonBOT
shrewd apex
glad cradle
#

@west niche

slate swan
slate swan
shrewd apex
#

;-; okie

slate swan
vocal snow
slate swan
#

bro

slate swan
#

i realised

#

is there an message contains tag?

cloud dawn
#

!d discord.Message.content

unkempt canyonBOT
vocal snow
#

but you should feel bad about it.

slate swan
#

and then an "123" in message.content

#

right?

cloud dawn
#

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.

silk fulcrum
#

👋 hey. what's wrong with pandas here?

slate swan
#

" hi "

#

would fix it

silk fulcrum
cloud dawn
pliant gulch
#

Just str.split

slate swan
#

who cares im using it to censor the n-word so hey

cloud dawn
#

I recommend fuzzy matching then.

silk fulcrum
cloud dawn
slate swan
silk fulcrum
#

lol

cloud dawn
slate swan
#

its like 6 lines of code

cloud dawn
#

Just look into the automod it's good.

slate swan
#

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

cloud dawn
#

It's a rule you can edit.

slate swan
#

yeah

#

iirc it doesnt use regex?

#

iirc they were going to impl it

cloud dawn
#

But like I said I recommend checking it out.

slate swan
#

im making it so my bot will say "AYOOOOO WT# (username)"

#

and tag me so i can come see what happend

silk fulcrum
#

why am i dumb

#

then why not code smth like this? lmao @slate swan

#

okay now it worked

cloud dawn
# slate swan yeah

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.

slate swan
#

is there an unrelated / memes channel

cloud dawn
unkempt canyonBOT
slate swan
#

thanks

#

that off topic channel sucks welp

cloud dawn
slate swan
#

also quick check higher() converts a message to higher case like lower() right?

slate swan
#

!d str.upper

#

ah thanks ok

unkempt canyonBOT
#

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.
cloud dawn
slate swan
#

channel.send(" AYOOOOOOO WTF "+user+" <@my id> COME LOOK AT THIS!")

#

!f-strings

unkempt canyonBOT
#

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.

slate swan
#

no need for str concatenation

pliant gulch
#

!e ```py
123 + "foo"

unkempt canyonBOT
#

@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'
slate swan
#

can two scripts run the same bot?

slate swan
cloud dawn
slate swan
#

mhm cool

slate swan
cloud dawn
slate swan
slate swan
slate swan
sick birch
cloud dawn
slate swan
pliant gulch
#

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

cloud dawn
#

"We do not mean hate to the company or it's employees. - This website is classified a parody under fair use."

sick birch
#

Parodies are covered under copyright so shitcord is fine

slate swan
# sick birch shitcord.com

Robin, no offence but.....I always think that your humour is no more than a 12-year-old 💀 "no offence"

slate swan
#

Robin has humor?

sick birch
slate swan
#

humout?

pliant gulch
#

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

slate swan
#

yeah, dont most vps have like water marks or something

#

like displaying who provides the server

vocal snow
slate swan
gilded gust
#

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?