#discord-bots

1 messages · Page 1013 of 1

slate swan
#

☠️

gaunt ice
#

did u update it

formal basin
formal basin
gaunt ice
#

which line is this event

#

I'm in mobile so

formal basin
gaunt ice
#

okk

formal basin
slate swan
gaunt ice
#

...

silver wolf
slate swan
#

I’m Boutta

gaunt ice
#

ot

gaunt ice
formal basin
gaunt ice
#

what's ephemeral

formal basin
silver wolf
# gaunt ice what's ephemeral

it means the message is only seen by the end user and the message itsnt officially sent through the API as a discord message

formal basin
#

Ask @quaint epoch

gaunt ice
#

ohh

#

alr ok

gaunt ice
#

try removing it?

formal basin
gaunt ice
#

@formal basin

formal basin
gaunt ice
#

alrr

abstract kindle
#

anyone know if you can hide the usage on slash commands

formal basin
#

It’s loading

gaunt ice
slate swan
formal basin
abstract kindle
#

where?

#

btw im talking about the little Diiisco used /shout thing

slate swan
abstract kindle
#

yeah sorry wasn't really descriptive on that

slate swan
#

I don’t believe you can change that

abstract kindle
#

¯_(ツ)_/¯

#

but if i use /shrug

#

it doesn't do it

slate swan
#

That’s built into discord

abstract kindle
#

must be a way

#

grrr

slate swan
#

Aliaster

#

What’s the websites domain again?

#

Nope

#

Idk then

formal basin
#

How can I add cooldowns to slash commands

#

It works but it won’t reply to the user saying that’s there on cooldown

slate swan
#

Try on_error instead of on_command_error

silver wolf
#

!d discord.app_commands.checks.cooldown

unkempt canyonBOT
#

@discord.app_commands.checks.cooldown(rate, per, *, key=...)```
A decorator that adds a cooldown to a command.

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns are based off of the `key` function provided. If a `key` is not provided then it defaults to a user-level cooldown. The `key` function must take a single parameter, the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.Interaction "discord.Interaction") and return a value that is used as a key to the internal cooldown mapping.

The `key` function can optionally be a coroutine.

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.app_commands.CommandOnCooldown "discord.app_commands.CommandOnCooldown") is raised to the error handlers.

Examples

Setting a one per 5 seconds per member cooldown on a command:
silver wolf
#

click the link to see the full example

#

not really. But the one I use, i haven't paid more than $1.10 a month. Not free but, pretty cheap

formal basin
#

It puts it in the console for some reason

silver wolf
#

show ur code

formal basin
silver wolf
formal basin
formal basin
silver wolf
formal basin
silver wolf
# silver wolf

plus ur using on_command_error, thats not how its shown in the example

slate swan
#

is this the wrong channel

silver wolf
#

because the documents I've shown are for discord.py 2.0

formal basin
silver wolf
silver wolf
#

then u have to upgrade to 2.0. slash commands are only in 2.0

formal basin
silver wolf
formal basin
#

Why is slash commands harder than normal commands

silver wolf
#

did u upgrade?

#

nothings gonna work if u dont upgrade

paper sluice
#

can i not annotate slash commands with discord.channel?

silver wolf
formal basin
silver wolf
#

exactly, because anything and everything related to slash commands are only 2.0

formal basin
#

It’s done but the problem is it’s putting in the console instead of the channel

silver wolf
#

i see that ur slash command above was slash.slash, and im pretty sure thats not discord.py. if ur using another lib then im not sure how to do the cooldown

slate swan
#

Could you Dm your pfp, thanks

light violet
#
gg = json.loads(doxreq.text)```

UnboundLocalError: local variable 'json' referenced before assignment```
how to fix this error

formal basin
#

Can you just explain to me why it won’t send the error in the Chat

unkempt canyonBOT
#

xy-problem

The XY problem can be summarised as asking about your attempted solution, rather than your actual problem.

Often programmers will get distracted with a potential solution they've come up with, and will try asking for help getting it to work. However, it's possible this solution either wouldn't work as they expect, or there's a much better solution instead.

For more information and examples, see http://xyproblem.info/

formal basin
#

Can you just explain to me why it won’t send the error in the Chat

#

Because I don’t understand why

#

What have I done wrong here it’s sending it in the console why can’t it send it in the chat

silver wolf
#

What u might have done wrong is that u could be using isinstance for the wrong parameter. Usually with slash commands, there's only the error and interaction, no ctx, so the library might not be passing the value ur expecting. when it comes to on_command_error, make sure parameters match because from what ive seen other libs do is

Regular command

async def on_command_error(ctx, error):
    ...

Slash command

async def on_slash_command_error(interaction, error):
    ...

Not what u have where its both ctx and an interaction. But it all depends on ur library of choice.

silver wolf
#

dont know of any sorry. i searched up and down in the past for a free one but i just couldn't find a free AND reliable one. came to the conclusion that with stuff like VPS, ur gonna have to pay. unless u use heroku or replit (which u've stated u dont want to use)

boreal ravine
latent anchor
#

there is a error called init() missing 1 required keyword-only argument: 'intents'
i have tried googling but all of the answers dont work

#

what should i do?

boreal ravine
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

latent anchor
#

oh wow ok

#

ty

boreal ravine
#

👌

slate swan
#

does anyone here know python json?

regal pulsar
#

*discord.ApplicationCommandInteraction

lyric apex
#

How can i access the deleted image for permanent like i am using a event it send the deleted image after some time we are unable to access it

lyric apex
#

Why other bots do

slate swan
#

how do u know theyre deleted

boreal ravine
boreal ravine
lyric apex
#

How others bot can do it then

vale wing
#

Digital ocean free 100$ credit

#

Amazon AWS 1 year free some weak server

silver wolf
vale wing
#

I don't even save them

boreal ravine
silver wolf
lyric apex
#

I will try pithink

silver wolf
#

but then if ur bot restarts, all the data will be lost so thats the bad side @lyric apex

vale wing
#

await attachment.to_file() and there you go, works fine for not heavy ones

lyric apex
vale wing
#

If you need to resend the deleted message in logs for example

silver wolf
abstract kindle
#

is it possible to use context menus in cogs

#

since they require 2 parameters exactly

slate swan
#

why does it not work?

slate swan
vale wing
#

Why'd you need to make it optional tho

silver wolf
scarlet sorrel
#

how do i get time for a message? can you do message.time() or something like that? also preferably as accurate as possible

strong vessel
#

time.time()?

#

idk

scarlet sorrel
#

no, time for when the message was sent, not current time

silver wolf
unkempt canyonBOT
scarlet sorrel
#

hmm

abstract kindle
#

Yo

#

Like he doesn't reload his code or any cogs

#

Nvm I found it, it's somethign called nodemon

rain salmon
#

TypeError: init() missing 1 required keyword-only argument: 'intents'

#

TypeError: init() missing 1 required keyword-only argument: 'intents'

#

how do i fix it?

scarlet sorrel
#

guys i have this code

from datetime import datetime
import time as timeorsomething
import datetime as etad
start = timeorsomething.time_ns()

but i always get TypeError: 'datetime.datetime' object is not callable no matter what i import any of them as

#

oops

#

ment to put in general

slate swan
#

I want to send a message to a server every 30 minutes What should I do?

#

is there a way to make discord bot which gives role when you have invite link in your status

cobalt jacinth
supple thorn
#

!d discord.on_presence_update

unkempt canyonBOT
#

discord.on_presence_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their presence.

This is called when one or more of the following things change:

• status

• activity...
rain salmon
cobalt jacinth
supple thorn
#

Use a task

rain salmon
#

oh

slate swan
rain salmon
#

damn

supple thorn
#

!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/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
supple thorn
#

Oh wrong person

slate swan
#

@bot.event()
async discord.on_presence_update(before, after)

#

?

supple thorn
#

No

#

It's just on_presence_update since you have already imported discord

#

I would hope so

#

@slate swan hi

slate swan
stone beacon
#

It's on_presence_update regardless of u imported it or not

paper sluice
#

u didnt call View

#

u didnt create an instance of View before calling to_components()

supple thorn
vale wing
#

No brackets no object

paper sluice
#

View.to_components()

TypeError: View.to_components() missing 1 required positional argument: 'self'
supple thorn
#

Hello ryuga

paper sluice
#

hi

vale wing
#

Look upside it's internal

supple thorn
#

How many guilds exe

latent anchor
#

how do i enable tracemalloc

vale wing
boreal ravine
supple thorn
#

Maybe a await issue?

latent anchor
supple thorn
#

Nevermind

boreal ravine
#

no, you forgot to await something

supple thorn
vale wing
#

@latent anchor you just didn't await something you don't need to enable it

vale wing
latent anchor
#

load extension cant be awaited

boreal ravine
#

don't await it if you're not using d.py

supple thorn
latent anchor
#

it just showes this
RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited

supple thorn
#

I forgot it's name

vale wing
#

Well I got no host now

supple thorn
#

😔

vale wing
#

Nah no server to host it on

#

I will try to build my own server today

paper sluice
vale wing
#

Because free cloud hosting doesn't exist for russians now

#

Already got ubuntu server iso

latent anchor
vale wing
latent anchor
vale wing
#

Async all setups

slate swan
vale wing
#

add_cog is async too?

supple thorn
unkempt canyonBOT
#

Concurrency in Python

Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the asyncio library, which is included in the Python standard library.

This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in other threads.

To call an async function we can either await it, or run it in an event loop which we get from asyncio.

To create a coroutine that can be used with asyncio we need to define a function using the async keyword:

async def main():
    await something_awaitable()

Which means we can call await something_awaitable() directly from within the function. If this were a non-async function, it would raise the exception SyntaxError: 'await' outside async function

To run the top level async function from outside the event loop we need to use asyncio.run(), like this:

import asyncio

async def main():
    await something_awaitable()

asyncio.run(main())

Note that in the asyncio.run(), where we appear to be calling main(), this does not execute the code in main. Rather, it creates and returns a new coroutine object (i.e main() is not main()) which is then handled and run by the event loop via asyncio.run().

To learn more about asyncio and its use, see the asyncio documentation.

paper sluice
#

yes

supple thorn
boreal ravine
vale wing
#

Then just make every fricking thing async

latent anchor
supple thorn
vale wing
paper sluice
slate swan
vale wing
supple thorn
slate swan
latent anchor
paper sluice
#

so many ducks ducky_australia

supple thorn
vale wing
#

You can subclass bot and load all extensions in overridden start method @latent anchor

supple thorn
#

Or do you want to discuss something

vale wing
#

Music generation bot 😩

slate swan
latent anchor
#

ive seen it beofore but i didnt use it

vale wing
# latent anchor bot.start?
class MyBot(commands.Bot):
    async def start(self, *args, **kwargs):
        # load extensions here

        await super().start(*args, **kwargs)

bot = MyBot(...)```
supple thorn
vale wing
boreal ravine
#

they should load extensions in the setup_hook method

vale wing
supple thorn
latent anchor
#

now the bot can run but it cannnot load extensions and react to messages

supple thorn
#

Not quite sure since i don't use discord.py 2.0 and don't have to await extensions

boreal ravine
vale wing
latent anchor
vale wing
#

And yeah as @boreal ravine said it should be

class MyBot(commands.Bot):
    async def setup_hook(self):
        await self.load_extension("ext.ext1")
        # and so on if not use listdir which is better ofc```
rain salmon
#
import discord
import randfacts
import requests
from discord import Intents
intents = discord.Intents.default()
intents.typing = True
intents.presences = False
client = discord.Client(intents=intents)


@client.event
async def on_ready():
    print('Running...'.format(client))


@client.event
async def on_message(message):
    request = requests.get(url='https://catfact.ninja/fact?max_length=140')
    if message.author.bot:
        return
    if message.author == client.user:
        return
    elif message.content.startswith('.catfact'):
        await message.reply(f"The cat fact is: {request.json()['fact']}")
    elif message.content == '.meh':
        await message.reply(".meh")
    elif message.content.startswith('.fact'):
        await message.reply(f"The random fact is: {randfacts.get_fact()}")

#

the bot is running but not answering

#

i have done something wrong but idk what it is

slate swan
supple thorn
paper sluice
cursive oxide
#

🤔 lets say i want to send send a post in a discord channel which automatically gets posted to reddit

how do i go about it?

rain salmon
#

i need it to change every time u press .catfact

paper sluice
#

make a command

rain salmon
#

it used to work but for some reason it stopped

paper sluice
#

sending requests especially with a blocking lib like requests is slow

#

make a command and name it catfact

#

so that u send minimal requests

rain salmon
#

i am not very good with these

#

what do u mean?

#

so i should remove the request = requests.get(url) from the def

rain salmon
paper sluice
# rain salmon so i should remove the request = requests.get(url) from the def

yea, remove it from on_message, so discord.py has this called commands they get called everything someone types <prefix><command_name>

import discord
from discord.ext import commands

@bot.command(name="name here if you want a different one than the function name", description="describe it here", hidden=False) #set hidden to True to hide it in the help
async def mycommand(ctx, argument1, argument2):
    '''A longer description of the command
    
    Usage example:
    !mycommand hi 1
    '''
    await ctx.send(f"Got {argument1} and {argument2}")

this is an example of basic command

rain salmon
#

i didnt understand what should i put in the description

#

and inside the mycommand

slate swan
rain salmon
#

xd

slate swan
#

or you can custom help command

paper sluice
rain salmon
#

and neither in name?

paper sluice
rain salmon
#
 if message.author.bot:
        return
    if message.author == client.user:
        return
    elif message.content.startswith('.catfact'):
        await message.reply(f"The cat fact is: {request.json()['fact']}")
    elif message.content == '.meh':
        await message.reply(".meh")
    elif message.content.startswith('.fact'):
        await message.reply(f"The random fact is: {randfacts.get_fact()}")
paper sluice
rain salmon
#

so this

slate swan
#

basic command is

@bot.command()
async def say(ctx, *, msg=None):
  await ctx.send(msg)
boreal ravine
rain salmon
#

i am not using tutorial

rain salmon
#

yea i removed 2 of em

slate swan
rain salmon
#

xd

#

Unresolved attribute reference 'command' for class 'Client'

slate swan
#
#Importing the Required Libraries
import discord
from discord.ext import commands

intents = discord.Intents.default() #Defining the intents for the application
intents.message_content = True #Required for Discord.py 2.0 | Enabling the message_content intent so as to make the *prefix* commands work
intents.members = True #Enabling the members intent to get permissions to view their info using our app

bot = commands.Bot(command_prefix="!", intents=intents, description="A Basic Bot based on Discord.py 2.0", activity=discord.Game(name="with you"), status=discord.Status.idle) #Defining the Bot

@bot.listen("on_ready") #A decorator to register a function as an event listener. In our case, this will print something when our bot is successfully connected to the discord api gateway and ready to use
async def on_ready():
    print(f"{bot.user} is online!")

@bot.command(name="ping", description="Get the ping of the bot") #A decorator to register the function as a command for the bot
async def _ping(ctx: commands.Context): #initiating the command function. The logic inside this function will determine the behaviour of the command
    await ctx.send(f"My ping is {round(bot.latency) * 1000}ms!") #sending back a response. Here, sending the bot's latency back to the author

@bot.command(name="embed", description="Embed any text")
async def _embed(ctx: commands.Context, *text: str):
    embed = discord.Embed(description=text, color=ctx.author.color) #making an embed
    await ctx.send(embed=embed) #sending the embed using the *embed* kwarg in the *send* method

bot.run("token") #running the bot. Pass your bot's token into the *run* method. 

Here's a short example

rain salmon
#

ohh ok tyvm

slate swan
supple thorn
slate swan
supple thorn
slate swan
supple thorn
slate swan
lyric apex
#

How can i make a bot without prefix?

supple thorn
#

Man whenever i say uwu i always think of the woohoo from the sims

supple thorn
#

Or just commands.Bot with only on_message

lyric apex
#

Like it funtion with prefix if used and if not prefix selected peeps can use it @supple thorn

slate swan
lyric apex
#

How will i do that

minor totem
#

How will the commands look like then?!

minor totem
#

I mean- how do you use the bot without a prefix?

supple thorn
#

Why would you want this

slate swan
#

☠️

lyric apex
#

I am wanting something unique in bot features so

slate swan
slate swan
slate swan
#

its a lot different

slate swan
slate swan
minor totem
# slate swan slash commands

That's distinctly different from message commands with one person being able to "use bot without prefix" if I understand things correctly

supple thorn
#

Elden ring was not one of them

slate swan
slate swan
supple thorn
slate swan
#

Free game 🤷‍♂️

#
    async def on_member_join(self, member):```
i want to extract member's avatar url, i am using this
`embed.set_thumbnail(url=member.avatar_url)`
but it is throwing error
vale wing
#

Ez

slate swan
slate swan
#

It changed in 2.0

lyric apex
supple thorn
slate swan
#

lmaooooo

vale wing
#

!d discord.ext.commands.Bot.command_prefix read about the function you can parse to there @lyric apex

unkempt canyonBOT
#

The command prefix is what the message content must contain initially
to have a command invoked. This prefix could either be a string to
indicate what the prefix should be, or a callable that takes in the bot
as its first parameter and discord.Message as its second
parameter and returns the prefix. This is to facilitate “dynamic”
command prefixes. This callable can be either a regular function or
a coroutine...

supple thorn
#

I don't think i can say that word

#

Describing best option

slate swan
#

Wtf is a female blunt 6’ object

#

OH

supple thorn
#

Lmfao

#

I think the female word gave it away

vale wing
#

Didn't sync yet

slate swan
vale wing
#

Or didn't sync at all depends on lib

#

Yes

slate swan
#

Don’t think they would appreciate a “toy” at their door

slate swan
vale wing
#

What library do you have

#

Well sorry I don't know about it

supple thorn
slate swan
slate swan
supple thorn
slate swan
#

I’m allready on the verge of getting the shit beaten out of me so I don’t think that’s a very good idea

vale wing
#

@slate swan anyways try to wait for ~1 hour and see if your commands appear also make sure you authorised your bot with application.commands scope

slate swan
vale wing
#

As for pycord I have no idea what you can do else

supple thorn
slate swan
stone beacon
#

Moyai

slate swan
#

I’m not mfing black dawg 💀

#

Wrong place shit

supple thorn
lyric apex
#

How can i make this for a channel or user only?

supple thorn
unkempt canyonBOT
#

@check_once```
A decorator that adds a “call once” global check to the bot.

Unlike regular global checks, this one is called only once
per [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") call...
supple thorn
#

Check the author's id and see if it matches the one you want to let use that horrific prefix

slate swan
#

Hey skev

#

👋

lyric apex
#

Bro my bot responds to -help But it doesn't Responds to -Help can i make it work without making aliases for it?

supple thorn
lyric apex
supple thorn
#

Oh wait nevermind

supple thorn
unkempt canyonBOT
#

Whether the commands should be case insensitive. Defaults to False. This
attribute does not carry over to groups. You must set it to every group if
you require group commands to be case insensitive as well.

supple thorn
#

I don't know why i thought this was for the prefix

slate swan
#

hello

#

so my bot uses ctx how do i use multiple context variables

slate swan
#

example py async def testcmd(ctx, *, hi, hello) await ctx.send(f'you said {hi} and {hello}' )

#

i want it like this

#

@supple thorn

slate swan
supple thorn
slate swan
#

but how would u make multiple contexts

supple thorn
#

Looks like a simple snippet of a test command

supple thorn
slate swan
supple thorn
#

Well

#

Yes

supple thorn
unkempt canyonBOT
#

await get_context(origin, /, *, cls=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Returns the invocation context from the message or interaction.

This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands")
to allow users more fine grained control over the processing...
supple thorn
#

You can get different context from messages

slate swan
supple thorn
#

And just use them like ctx

#
poopybutthole = await bot.get_context(message)
paper sluice
#

interesting name

supple thorn
#

Also thank you

paper sluice
#

for?

supple thorn
paper sluice
#

oh 👍

ocean steeple
#

Yo

lyric apex
paper sluice
#

cat lemon_hyperpleased

ocean steeple
#

Can I host my discord bots with clouds?

#

ik that's stupid question but ok

paper sluice
rain salmon
#

it finally worksss

#

omg happy me

supple thorn
rain salmon
#

discord bot i made

supple thorn
rain salmon
#

my stupidity xd

supple thorn
#
@bot.check_once
def whitelist(ctx):
    return ctx.message.author.id in my_whitelist
#

Here is the example from the docs

lyric apex
#
@bot.check_once
def whitelist(ctx):
    my_whitelist = "680994218977787927"
    return ctx.message.author.id in my_whitelist```
#

I used this it return left side uses string not int*

supple thorn
#

You're comparing a string to an int

#

Remove the ""

slate swan
#

why the heck is this giving me self.load_extension('jishaku')
this error - Extension 'jishaku' raised an error: TypeError: cogs must derive from Cog

paper sluice
#

jishaku is not a valid file name

slate swan
#

I even tried the ways that the docs suggested

#

smh

lyric apex
#

@supple thorn

paper sluice
#

i think u need a file called jishaku where u need to import jishaku and have a setup function init

boreal ravine
paper sluice
#

*u changed it

slate swan
#

Hi im back

paper sluice
#

sup back

slate swan
boreal ravine
#

whats jishaku? carrots jsk? gorialis's jsk?

boreal ravine
paper sluice
#

!pip jishaku

unkempt canyonBOT
slate swan
#

uhhhhhhhhhh

slate swan
slate swan
slate swan
supple thorn
#

Happens when you copy code in a codebloco from discord

boreal ravine
unkempt canyonBOT
slate swan
#

wow

boreal ravine
#

use that one

slate swan
#

thanks a lot

hybrid ravine
#
Traceback (most recent call last):
  File "C:\Users\xylo7\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "azure2.py", line 231, in on_ready
    members = guildobj.members
AttributeError: 'NoneType' object has no attribute 'members'
``` any help?
dire folio
#

Send ur code

hybrid ravine
# dire folio Send ur code
@client.event
async def on_ready():
    os.system('cls||clear')
    global members
    members = guildobj.members```
slate swan
boreal ravine
slate swan
supple thorn
hybrid ravine
slate swan
supple thorn
#

Welp ima sleep

#

Quack you guys later

slate swan
#

why the heck arent my jsk commands working 😔

supple thorn
slate swan
paper sluice
#

ay jishaku is kinda cool

maiden fable
slate swan
#

I mean, they dont anymore*

hybrid ravine
slate swan
#

@maiden fable like it doesnt show up in the help command, but when I pass the subcommand, it does show

#

I think

#

!d discord.Guild.members

unkempt canyonBOT
hybrid ravine
hybrid ravine
slate swan
#

It hasn’t found the guild

boreal ravine
#
cmd = commands.Command(asyncio.coroutine(lambda ctx: ctx.send(1)), name='hi')

one liner ez

slate swan
#

If it doesn’t find the guild it returns none type

hybrid ravine
#

above it and it doesnt print err

slate swan
#

It returns a none type

#

It handles it for you

slate swan
#

the commands dont even work

#

how can i make it so that when a message is sent in a specific channel the bot messages them

hybrid ravine
boreal ravine
#

errors?

slate swan
#

wait.for

#

@bot.event
async def on_message(message):
if (message.channel.id == 'channel id'):
await message.channel.send('message goes here')

slate swan
#

idk how i could use it in this context

boreal ravine
slate swan
slate swan
hybrid ravine
slate swan
hybrid ravine
#

i checke like 10x

slate swan
hybrid ravine
slate swan
slate swan
slate swan
#

Copying someone’s Code is bad practice because you don’t fully understand it so you won’t be able to fix any errors caused by it

slate swan
#

await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))

hybrid ravine
slate swan
#

That’s the code for a presence object

slate swan
hybrid ravine
slate swan
shell hill
#

how do i change the actual name of the help command

#

like i want to have the help command work when someone says !assist instead of !help

slate swan
#

bot wait for messages in channel

#

how can i do that

sick birch
slate swan
#

That’s a wild guess

slate swan
#

but i want to wait for messages

brave forge
#

who has a link to discord.py the new version, and that is 3.8
preferably a link to the git hub

slate swan
#

rapptz

#

on github

sick birch
slate swan
#

msg = await bot.wait_for(event = 'message', check = check, timeout = 60.0)

#

would something like this work

brave forge
# sick birch https://github.com/Rapptz/discord.py

ERROR: Cannot unpack file C:\Users\ToxicPenguin\AppData\Local\Temp\pip-unpack-7y59g8v3\discord.py (downloaded from C:\Users\ToxicPenguin\AppData\Local\Temp\pip-req-build-zts93rgu, content-type: text/html; charset=utf-8); cannot detect
archive format
ERROR: Cannot determine archive format of C:\Users\ToxicPenguin\AppData\Local\Temp\pip-req-build-zts93rgu

#

@sick birch not working

shell hill
#

@slate swan it didnt work

slate swan
#

Yeah I guessed that 💀

#

Lemme find you an actual solution

shell hill
#

oh ok

#

tyy

brave forge
#

who has a link to discord.py the new version, and that is 3.8
preferably a link to the git hub

#

who has a link to discord.py the new version, and that is 3.8
preferably a link to the git hub

slate swan
#

Raptzz GitHub

#

There are example views

#

Check confirm.py for a deatailed example of buttons

slate swan
# shell hill oh ok
bot = commands.bot(‘!’, help_command=None)

@bot.command()
async def assist(ctx):
    await ctx.send(commands.Command.help)
shell hill
#

TYSM :))) @slate swan

brave forge
#

@slate swan you have a link to the github where there is ... the version on which the buttons work ?

slate swan
#

how to make it so that after the bot waits

#

it sends something to the user that sent the message

#

check=check probably

brave forge
#

@slate swan Are you kidding me?

archive format
ERROR: Cannot determine archive format of C:\Users\ToxicPenguin\AppData\Local\Temp\pip-req-build-il6u2836```
slate swan
#

pip install -U git+https://github.com/Rapptz/discord.py@rewrite

#

I think

brave forge
# slate swan pip install -U git+https://github.com/Rapptz/discord.py@rewrite
ERROR: Command errored out with exit status 1: git checkout -q rewrite Check the logs for full command output.
WARNING: You are using pip version 21.2.2; however, version 22.0.4 is available.
You should consider upgrading via the 'c:\users\toxicpenguin\appdata\local\programs\python\python39\python.exe -m pip install --upgrade pip' command.```
slate swan
#

Try that instead

brave forge
#

@slate swan OMG now my bot doesn't start stupidly

granite parcel
#

how to make user specific prefix?

brave forge
#

@slate swan File "c:\Users\ToxicPenguin\Desktop\disocrd bot python\index.py", line 8, in <module> bot = commands.Bot (command_prefix = ',') TypeError: __init__() missing 1 required keyword-only argument: 'intents'

slate swan
maiden fable
brave forge
slate swan
#

!d discord.ext.commands.Bot.intents

unkempt canyonBOT
slate swan
#

!d discord.Intents.all

unkempt canyonBOT
#

classmethod all()```
A factory method that creates a [`Intents`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents "discord.Intents") with everything enabled.
slate swan
#

and now I know what the error is

brave forge
#

bitch what the hell when I install a new version of python everything breaks!? What the fuck is this discord.py !? Why the fuck can't he install a new version just through pip install discord.py , and installs an outdated fuck. To understand this Discord.py who should I be!?

brave forge
# slate swan Calm down tbh

already pisses me off. These damn buttons came out 100 years ago, and in discord.py this shit only works with the version "I fucked the mother of this motherfucker who invented this shit!!!"

slate swan
brave forge
#

how is it normal to say something here?

brave forge
heady sluice
#

I'm gonna ping mods if you don't stop

silver wolf
slate swan
heady sluice
slate swan
brave forge
slate swan
red sundial
#

💀

brave forge
#

@heady sluice yes.

heady sluice
#

wanna find out?

red sundial
#

bro if you have a problem with pip no one can help 💀

silver wolf
slate swan
silver wolf
#

@slate swanshow code

brave forge
#

@silver wolfyes discord.py not officially. But the functions are already on discord.py figs understand which version that does not work on this 1.7.3

silver wolf
#

what library are u using

#

show ur code for the slash command

slate swan
#

hm, does disnake modals allow multi-line input?

silver wolf
#

one will suffice

#

because its set as global. which takes about an hour for it to show up. if u want to use it right away, u have to specify the guild to which it can be used

@bot.slash_command(guild_ids=[...])
async def shop(ctx, ...):
    ...
#

exactly, so u need to do testing in a single server, because nobody wants to wait an hour just to make sure their code is working properly. when testing, test in a specific guild, when live, then set it as global

#

specific guild = right away
all guilds = about 1 hour

#

just ping me here. i'll be online

slate swan
#

how would I get the channel ID when a command is used

slate swan
#

ah yeah

#

should of looked at the structure for ctx

#

:(

heady sluice
#

imagine lowercase

#

dpy follows pep8

slate swan
#

I stg I’m gonna fucking

heady sluice
#

and the docs don't work like that

#

!d discord.ext.commands.Context.channel

unkempt canyonBOT
heady sluice
#

returns discord.TextChannel

unkempt canyonBOT
slate swan
#

Yeah yeah whatever

regal pulsar
#

and how many guilds to bot is in

slate swan
#

Why don't I have an icon and the exact time?

slate swan
#

Souly discord rich presence with visual studio code

#

Hello what i do? " ModuleNotFoundError: No module named 'discord' "

slate swan
#

it is related to IDE for python

slate swan
#

Example:

#

IDE ?

#

what is it ?

slate swan
#

visual studio code

slate swan
#

oh okay

slate swan
# slate swan Example:

Still nothing to do with this discord server but you need a discord rich presence extension

#

first one is better option i beleive

#

but still it has nothing to do with this server

slate swan
#

Import "discord" could not be resolved Pylance(reportMissingImports) [Ln 2, Col 8]

slate swan
#

yes

#

hm

#

Reinstall the module

#

pip3 install discord ?

#

ye

#

nothing

#

nothing?

#

again Import "discord" could not be resolved Pylance(reportMissingImports) [Ln 2, Col 8]

#

How can I host my bot in android 😔

slate swan
slate swan
#

Or heroku or aws

#

in android os

#

I mean

slate swan
#

Not those shity
sites

#

Pydroid 3 – IDE for Python 3

#

thats a python IDE for android

slate swan
slate swan
slate swan
# slate swan yes

go to C:\Users\AppData\Local\Programs\Python\Python37\Lib\site-packages

#

Ok

slate swan
#

Ok

slate swan
#

!e

import os
print(os.name)
#

i don't have python37 but python 310

#

:")

slate swan
paper sluice
slate swan
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

posix
slate swan
#

👀

slate swan
#

Posix

paper sluice
#

?

slate swan
slate swan
#

ok

#

Then restart your IDE and try again

tacit token
#
@setlang.error
async def on_command_error(self,error, ctx):
        if isinstance(error, MissingPermissions):
            await ctx.send("You dont have all permission for this command")

discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Utility' raised an error: AttributeError: 'CogCommandObject' object has no attribute 'error'

boreal ravine
slate swan
slate swan
#

it still doesn't work :/

paper sluice
slate swan
#

!d discord.ext.commands.Cog.cog_command_error

unkempt canyonBOT
#

await cog_command_error(ctx, error)```
A special method that is called whenever an error
is dispatched inside this cog.

This is similar to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") except only applying
to the commands inside this cog.

This **must** be a coroutine.
slate swan
slate swan
#

mmh no

#

no module named discord

#

whats the issue?

slate swan
slate swan
#

wrong reply but nvm

paper sluice
#

wait there is CogMeta, now imma make overloading for commands ducky_devil

heady sluice
paper sluice
#

c

heady sluice
#

!code

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.

heady sluice
#

also 7 spaces indents

#

oh

#

nvm

slate swan
#
print("Hello world!")
#

ooooh

#
print('Hello world!')
heady sluice
#

...

slate swan
#

Once you help everyone there is noone else to help PepeHands

vale musk
#

well

slate swan
#

well 🗿

vale musk
#

alr

slate swan
#

what ☠️

#

import discord

client = discord.Client

client.run("token")
#

right ?

sick birch
#

discord.Client()

#

It's a class, not a property

vale musk
#

🥲

slate swan
#

oh ok

sullen igloo
#

Hi

slate swan
#

yo

slate swan
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

Hello world!
slate swan
#

i am differentpithink

#
print("roses are red, violet are blue")

(unexpected lines 32)
#

bro

#

😭

slate swan
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

hello world!
slate swan
#

esoteric

#

price isnt a key

#

!e print({1: 2}[3])

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | KeyError: 3
slate swan
#

a valid key?

#

show the dict

#

bro

#

i stg

#

youre indexing a dictionary

halcyon bison
slate swan
#

i would download main

#

and not 1.7.3

tacit token
#

Guys, how can i set error to slash in cogs? if i use @command.error
Output:

discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Utility' raised an error: AttributeError: 'CogCommandObject' object has no attribute 'error'
slate swan
#

i want to print the status of my discord bot

tacit token
#

the problem is same for your code, its so sad

slate swan
#

ex: online, dnd, invisible and idle

slate swan
slate swan
#

what?

slate swan
slate swan
#

dont give him that example

#

i beg

#
bot = commands.Bot("!")
print(bot.status)
#

xd i have not tried that

#

!d discord.Member.status

unkempt canyonBOT
#

property status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") instead.
slate swan
#

JK IT DOESNT WORK BROOOOOOO

#

😤

tacit token
#

chill out 💀 😆

slate swan
#

OK ELON

slate swan
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

bob
slate swan
#

ew

#

basic oop lmao

lyric apex
slate swan
slate swan
slate swan
#

member.status would probably work

lyric apex
# lyric apex

How i get user mentioned ban reason , my code sends all guild banned members

slate swan
#

but bot.status doesnt

slate swan
# slate swan yes 🙏

you give a method of the member class and then pass it to the bot class thats worse than my wording💀

#

lmfao as said

#

bot.user.status

#

sorry 😭

#

xd

#

doesnt that return a ClientUser

#

🗿

#
  File "/home/maxmorin/Downloads/roro/main.py", line 44, in <module>
    print(bot.user.status)
AttributeError: 'NoneType' object has no attribute 'status'```
slate swan
#

print(bot.user.status)

slate swan
slate swan
#

!d discord.ext.commands.Bot.user

unkempt canyonBOT
slate swan
#

i know my stuff

slate swan
#

🙀

#

can u like do it 4 me

slate swan
lyric apex
slate swan
#

ive been searching for hours bro

#

just do it on connect

#

!d discord.on_connect

unkempt canyonBOT
#

discord.on_connect()```
Called when the client has successfully connected to Discord. This is not
the same as the client being fully prepared, see [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready") for that.

The warnings on [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready") also apply.
slate swan
#

underneath on ready?

slate swan
#

k

slate swan
#

and krypton long time no see🙀

#

idk what i did that for tbh 💀

slate swan
#

i leant something

#

I need help with this, if someone writes !daykey 1 it sends me a log to my webhook saying this person did that command

slate swan
#
from discord import Webhook, RequestsWebhookAdapter # Importing discord.Webhook and discord.RequestsWebhookAdapter

webhook = Webhook.from_url('webhook-url-here', adapter=RequestsWebhookAdapter()) # Initializing webhook
webhook.send(content="Hello World") # Executing webhook.```
slate swan
slate swan
#

idk what to call it mf

#

!d discord.Webhook

unkempt canyonBOT
#

class discord.Webhook```
Represents an asynchronous Discord webhook.

Webhooks are a form to send messages to channels in Discord without a
bot user or authentication...
slate swan
#

that whole sentence gave me a stroke😭

#

lmaoo

#

if message.content.lower == '!daykey 1':
webhook = Webhook.from_url('webhook-url-here', adapter=RequestsWebhookAdapter()) # Initializing webhook
webhook.send(content="Hello World") # Executing webhook.```
#

would it be that?

#

😭

slate swan
slate swan
#

!indents

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

unkempt canyonBOT
#
Not gonna happen.

No documentation found for the requested symbol.

paper sluice
#

:(

slate swan
#

😭

slate swan
slate swan
paper sluice
#
#some imports
import discord
from discord.ext import commands

@bot.command(name="name here if you want a different one than the function name", description="describe it here", hidden=False) #set hidden to True to hide it in the help
async def mycommand(ctx, argument1, argument2):
    '''A longer description of the command
    
    Usage example:
    !mycommand hi 1
    '''
    await ctx.send(f"Got {argument1} and {argument2}")
slate swan
#
from discord import Webhook, RequestsWebhookAdapter # Importing discord.Webhook and discord.RequestsWebhookAdapter

webhook = Webhook.from_url('webhook-url-here', adapter=RequestsWebhookAdapter()) # Initializing webhook
webhook.send(content="Hello World") # Executing webhook.```
#

🤨

#

LMAO if !daykey 1 if written i want the url to be sent

#

i said that so wrong holy

#

if !daykey 1 is written it sents a message to the webhook

slate swan
#
from discord import Webhook, RequestsWebhookAdapter
webhook = Webhook.from_url('webhook-url-here', adapter=RequestsWebhookAdapter())

@bot.command()
async def daykey(ctx, arg):
    if arg == 1:
        webhook.send(content="command was used")```
slate swan
#

arg will never be 1 if you don't type hint it to an integer (arg: int)

#

and webhook.send is a coro

#

!d discord.Webhook.send

unkempt canyonBOT
#
await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message using the webhook.

The content must be a type that can convert to a string through `str(content)`...
slate swan
#

God I hate Python CL0_KEKLeave

slim citrus
#

need help with a music bot ?

slate swan
#

No we don't need help for that

slim citrus
#

as in i need help xD

slate swan
#

Maybe in the other hand you do?

slate swan
slim citrus
#

yes

torn sail
#

!ydtl

slate swan
#

Ask your question, we will see if we can answer

torn sail
#

something about that

slate swan
#

Don't just make direct suppositions. Playing a local mp3 file is not against any rule and can be considered as a music bot.

#

find all the wierd loopholes so we can help you with your music bot without getting a mods dick up our arseholes

#

!!!

slim citrus
#

wym ?

slate swan
#

Just ask your question :)

slim citrus
#

oh okay

slate swan
#

We will then see if we can answer it

slim citrus
#

i keep getting this error

lyric apex
#

How do i make User specific prefix i am confused so muchshipit

torn sail
#

in line 5

slim citrus
#

cog needs to be cap ?

slate swan
#

Well now it goes to the ytdl tag unfortunately we cannot help

#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slim citrus
#

you cant use ytdl ?

slate swan
#

you can but it it breaks the TOS (youtube's)

slate swan
slim citrus
#

what can i do instead

slate swan
#

You can, it's just beaching terms of service of YouTube and we don't provide help to breach terms of services.

slim citrus
slate swan
slate swan
#

this is all wrong

#

delete that message now

slim citrus
#

....

slate swan
#

thanks

slim citrus
wary crystal
slate swan
#

As already said, you won't really get any help as we don't help for projects that breach the terms of services.

slate swan
slate swan
slim citrus
slate swan
#

Not only this KEKW

wary crystal
slate swan
slate swan
slate swan
torn sail
wary crystal
slate swan
slim citrus
slate swan
#

That's YouTube

#

ytdl is just getting youtube audio files

slate swan
#

and other services

#

you can get music from elsewhere

slim citrus
#

spotify ?

wary crystal
slate swan
slate swan
slate swan
#

Almost all music providers do not allow music streaming and downloading.

#

if a command is sending a message to my webhook, how can i @ the user who did the command?

#

You can't really do a music bot without breaching a terms of service.

slim citrus
#

oh well

slate swan
#

!d discord.Member.mention

unkempt canyonBOT
wary crystal
# slate swan without an AbstractEventLoop*

Not sure how that has to do with your point though? All code bases are easy to infect with asynchronous code regardless of the language. That's just the nature of the paradigm itself

slate swan
#

regardless of the language
Not really no

torn sail
wary crystal
#

On what basis

slate swan
#

webhook.send(content="Day key has been created" + {ctx.author.mention})

#

!f-strings

#

when i do that command it doesn;t work

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
#

any fixes for that

#

Yes, read the message above sent by the bot

#
@bot.command()
async def calculator(ctx):
    m = await ctx.send(content='Loading Calculators...')
    expression = 'None'
    delta = datetime.datetime.utcnow() + datetime.timedelta(minutes=5)
    e = discord.Embed(title=f'{ctx.author.name}\'s calculator | {ctx.author.id}', description=expression,
                        timestamp=delta)
    await m.edit(components=buttons, embed=e)
    while m.created_at < delta:
        res = await bot.wait_for('button_click')
        if res.author.id == int(res.message.embeds[0].title.split('|')[1]) and res.message.embeds[
            0].timestamp < delta:
            expression = res.message.embeds[0].description
            if expression == 'None' or expression == 'An error occurred.':
                expression = ''
            if res.component.label == 'Exit':
                await res.respond(content='Calculator Closed', type=7)
                break
            elif res.component.label == '←':
                expression = expression[:-1]
            elif res.component.label == 'Clear':
                expression = 'None'
            elif res.component.label == '=':
                expression = calculate(expression)
            else:
                expression += res.component.label
            f = discord.Embed(title=f'{res.author.name}\'s calculator|{res.author.id}', description=expression,
                                timestamp=delta)
            await res.respond(content='', embed=f, components=buttons, type=7)```
#

Tbh we don’t speak Russian