#discord-bots

1 messages · Page 119 of 1

upbeat gust
#

Don't auto sync, use a text command

#

Why do you have a ext.commands error handler instead one for your tree

south coyote
#

here let me show you what i did

slate swan
#

my bot was working fine yesterday but i launch today and it doesnt print anything at all except for that?

upbeat gust
#

Why are you doing try/except just to print out the error? Remove that

south coyote
#
import discord
from discord import app_commands
from discord.ext import commands


#intents = discord.Intents.default()
#intents.message_content = True


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

@bot.event
async def on_ready():
    print(f'We have logged in as {bot.user}')
    try:
        synced = await bot.tree.sync()
        print (f"Synced {len(synced)} command(s)")
    except Exception as e:
        print (e)

@bot.tree.command(name='support')
@commands.has_role('verified')

async def support(interaction: discord.Interaction):
    channel_name=(f"help--{interaction.author.name}")
    guild = interaction.guild
    existing_channel = discord.utils.get(guild.channels, name=channel_name)
    if not existing_channel:
        print(f'Creating a new channel: {channel_name}')
    await interaction.guild.create_text_channel(channel_name)

@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.errors.CheckFailure):
        await ctx.send('You do not have the correct role for this command.')

#bot.run('...')
upbeat gust
#

What about it

south coyote
#

File "/home/deusopus/make-a-channel.py", line 26, in support channel_name=(f"help--{interaction.author.name}") AttributeError: 'Interaction' object has no attribute 'author'

upbeat gust
#

!d discord.Interaction.user

unkempt canyonBOT
upbeat gust
#

Not author

#

Please look through the list of things that I said were wrong

south coyote
#

ok

#

why does it keep saying appliction not responding. its working fine

#

it making the channel

upbeat gust
#

Because you aren't responding

#

creating a channel isn't a response

slate swan
upbeat gust
#

interaction.response.XX is a response. Send a message, or defer

upbeat gust
#

Using dpy 2.0 and not getting any errors? This is on purpose, the library now uses logging to send errors but only if you're using Client/Bot.run. More about that in ?tag defaultlogging.

It's recommended to setup logging yourself if you aren't using .run or use the utils.setup_logging helper function: just put discord.utils.setup_logging() anywhere in your running file. Docs: https://discordpy.readthedocs.io/en/stable/api.html#discord.utils.setup_logging

but I can't use Client/Bot.run!
You can! You can load cogs and do other stuff in the newly added setup_hook method that is called once after the bot logs in, more about that and how to implement it in ?tag setuphook.

slate swan
#

Hii!

#

So I have a friend that's trying to install discord.py on VS code, he got this error, anyone knows what's up?

meager chasm
#

Instead of 3.11

#

Or follow the link in da error to get visual c++ 14 and then u can build the wheels

glad cradle
slate swan
#

I want to add a give command to my disocrd economy boy but I dont know how to type it in. Any ideas?

#

Im using SQL for my database

#

use a keyboard

slate swan
#

Lol

glad cradle
rugged shadow
slate swan
#

should i switch to nextcord?

silent zenith
#

How to check if the bot is in the same channel as the user?
also ignore the bottom print(ctx.voice_state)

slate swan
slate swan
#

for slash commands and for buttons

slate swan
silent zenith
#

oh thanks

slate swan
#

!d discord.ext.commands.Context.voice_client

unkempt canyonBOT
#

property voice_client```
A shortcut to [`Guild.voice_client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.voice_client "discord.Guild.voice_client"), if applicable.
silent zenith
#

thats what i was looking for

slate swan
silent zenith
#

is my logic here broken? if i play a song when the bot is already in a channel then it says "Diffrent voice channel"

slate swan
#

should be voice_client.channel

silent zenith
#

thanks

silent zenith
slate swan
#

!d discord.VoiceClient.is_playing

unkempt canyonBOT
silent zenith
#

thanks

#

ill look at the doocumentation

south coyote
#

hello

#

i can't get this code to work

#
import discord, os
from datetime import datetime
from discord import app_commands, utils
from discord.ext import commands


class ticket_launcher(discord.ui.View):
    def __init__(self) -> None:
        super().__init__(timeout=None)
        self.cooldown = commands.CooldownMapping.from_cooldown(1, 600, commands.BucketType.member)

    @discord.ui.button(label="Create a ticket", style=discord.ButtonStyle.blurple, custom_id="ticket_button")
    async def ticket(self, interaction: discord.Interaction, button: discord.ui.Button):
        ticket = utils.get(interaction.guild.text_channels, name = f"Support-Ticket-{interaction.user.name}-{interaction.user.discriminator}")
        if ticket is not None: await interaction.response.send_message(f"You already have a ticket open at {ticket.mention}!", ephemeral=True)
        else:
            overwrites = {
                interaction.guild.default_role: discord.PermissionOverwrite(view_channel = False),
                interaction.user: discord.PermissionOverwrite(view_channel = True, read_message_history = True, send_messages = True, attach_files = True, embed_links = True),
                interaction.guild.me: discord.PermissionOverwrite(view_channel = True, send_messages = True, read_message_history = True), 
                client.ticket_mod: discord.PermissionOverwrite(view_channel = True, read_message_history = True, send_messages = True, attach_files = True, embed_links = True),
            }
            
#
          try: channel = await interaction.guild.create_text_channel(name = f"Support-Ticket-{interaction.user.name}-{interaction.user.discriminator}", overwrites = overwrites, reason = f"Ticket for {interaction.user}")
            except: return await interaction.response.send_message("Ticket creation failed! Make sure I have `manage_channels` permissions!", ephemeral = True)
            await channel.send(f"{client.ticket_mod.mention}, {interaction.user.mention} created a ticket!", view = main())
            await interaction.response.send_message(f"I've opened a ticket for you at {channel.mention}!", ephemeral = True)

class aclient(discord.Client):
    def __init__(self):
        super().__init__(intents=discord.Intents.default())
        self.synced = False
        self.added = False

    async def on_ready(self):
        await self.wait_until_ready()
        
        if not self.synced:
            await tree.sync(guild = discord.Object(id = '1037162557003276369'))
            self.synced = True
            
        if not self.added:
            self.add_view(ticket_launcher())
            self.added = True

        print(f"We have logged in as {self.user}")


client = aclient()
tree = app_commands.CommandTree(client)


@tree.command(name = "test", description = "testing", guild = discord.Object(id = '1037162557003276369'))
async def ticketing(interaction: discord.Interaction):
    embed = discord.Embed(title = "If you need support, click the button below and create a ticket!", color = discord.Colour.blue())
    await interaction.channel.send(embed = embed, view = ticket_launcher())
    await interaction.response.send_message("Ticketing system launched!", ephemeral = True)


client.run('...')
#

i followed the instruction verbatim

#

its supposed to make a channel

#

but its giving me an error response

silent zenith
slate swan
#

correct

#

did you disconnect the bot and reconnect it when you restarted the code?

south coyote
#

you mean like kick it?

slate swan
#

its a method, not a property

silent zenith
#

oh my, thanks

south coyote
#

any help?

slate swan
#

Application did not respond?

south coyote
#

yeah something like that

slate swan
south coyote
#

its saying "This interaction failed"

#

ah

#

i need to launch it first

#

is what you mean right?

slate swan
#

!d discord.InteractionResponse.defer

unkempt canyonBOT
#

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

Defers the interaction response.

This is typically used when the interaction is acknowledged and a secondary action will be done later.

This is only supported with the following interaction types...
silent zenith
#

every time i append url to the queue it just rewrites over it

south coyote
#

can you show me please

#

you put it first?

naive briar
#

Your queue is a local variable

silent zenith
#

i want it to be able to be accessed in the play function, i haven't implemented it yet

naive briar
#

I just realized something

#

Well uhh

#

I'm not allowed to help people about making music bots

slate swan
#

Hello Guys how can i add Proxy for my discord bot ?

silent zenith
#

i had 2 funstions named play

glad cradle
#

lmao I found 2 bug with discord.py and disnake Voice implementation

#

probably nextcord and other fork are affected too

slate swan
#

what is it?

silent zenith
#

@slate swan do you know the best way to tell when the voice client has finished playing the song?

glad cradle
# slate swan what is it?
GitHub

Summary A playing VoiceClient that gets moved in another VoiceChannel appear to stops reproducing the audio, though VoiceClient.is_playing() is True Reproduction Steps Join a VoiceChannel and repod...

GitHub

Summary When using a FFmpegPCMAudio audio source with a source that represent a non file-like object (e.g a url) and when disconnecting from a VoiceChannel you get an OSError. This bug was found wh...

topaz helm
#

Can someone help me with a mute command? Please, let it go well

south coyote
#

anyone know what this means?
Traceback (most recent call last): File "/home/deusopus/random-button.py", line 15, in <module> class aclient(discord.Client): File "/home/deusopus/.local/lib/python3.10/site-packages/discord/ui/button.py", line 281, in decorator raise TypeError('button function must be a coroutine function') TypeError: button function must be a coroutine function

#

here's the code...

import discord
from discord import app_commands
import random


yes_no = ["yes", "no"]

class random_bot(discord.ui.View):
    def __init__(self) -> None:
        super().__init__(timeout=None)

class aclient(discord.Client):
    def __init__(self):
        super().__init__(intents=discord.Intents.default())
        self.synced = False
        self.added = False

    async def on_ready(self):
        await self.wait_until_ready()
        
        if not self.synced:
            await tree.sync(guild = discord.Object(id = '1037162557003276369'))
            self.synced = True
            
        if not self.added:
            self.add_view(random_bot())
            self.added = True

        print(f"We have logged in as {self.user}")

client = aclient()
tree = app_commands.CommandTree(client)





@tree.command(name = "random", description = "answer yes or no", guild = discord.Object(id = '1037162557003276369'))
async def ticketing(interaction: discord.Interaction):
    embed = discord.Embed(title = "Think of a 'yes' or 'no' question and click the button!", color = discord.Colour.blue())
    await interaction.channel.send(embed = embed, view = random_bot())
    await interaction.response.send_message(random.choice(yes_no), ephemeral = False)



@discord.ui.button(label="Yes/No", style=discord.ButtonStyle.blurple, custom_id="YN_button")

client.run("...")
#

its just a button when you press it it gives you a random yes or no

topaz helm
#

Is this for mute? It doesn't seem like much

south coyote
#

are you working on a discord bot?

#

this is for people that are working on discord bots

slate swan
#

how can i put my custom emoji?

upbeat gust
#

How to show emotions for robots:
Custom emotes are represented internally in the following format:
<:name:id>
Where the name is the name of the custom emote, and the ID is the id of the custom emote.
For example, :python3: is the name:id for :python3:

When sending standard unicode/discord emojis, you just send the unicode character. This is handled differently from language to language, but in python, you can send \N{NAME}, the codepoint, \uFFFF, or just the unicode char itself: 🇦 You can get info on this by using the ?charinfo command

You can quickly obtain the <:name:id> format by putting a backslash in front of the custom emoji when you put it in your client.
Example: \:python3: would give you the <:name:id> format.

When adding reactions, you can either send the unicode for standard emojis, or send name:id, not <:name:id> for custom emojis.
New in 1.1.0 You can use <:name:id>

Animated emojis are the same as above but have an a before the name- ie: <a:name:id>

slate swan
#

I already tried like this :IconSwitchIconOff:

upbeat gust
#

did you even read what i sent

slate swan
#

loooli too long, didnt read

upbeat gust
#

heres what it should look like

#

formatting got a bit messed up

slate swan
upbeat gust
slate swan
#

that should work as long as the emoji id and name are correct

upbeat gust
#

Perms?

#

'use external emojis'

slate swan
#

*and its not an animated one, for animated you gotta add a before the first :

slate swan
slate swan
slate swan
upbeat gust
slate swan
upbeat gust
#

...

#

That's the message id

#

Read the thing I sent

slate swan
#

😭 not another person who used message id instead of emoji id

slate swan
slate swan
#

will give you the full escaped name

slate swan
upbeat gust
slate swan
slate swan
slate swan
#
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) ``` any fix please ?
silent zenith
#

How can i run a function when ffmpeg has finished playing a sound file?

glad cradle
south coyote
#

how do you make a discord.py button disappear after one use

glad cradle
glad cradle
worldly solstice
#

Is anyone here a gql wizard and can answer one (i think fairly simple) question to me by any chance?

south coyote
#

you remove the button from the view?

#

sorry im new

glad cradle
unkempt canyonBOT
#

remove_item(item)```
Removes an item from the view.

This function returns the class instance to allow for fluent-style chaining.
worldly solstice
#

Ok so when querying something i usually use

json_data = {
        'operationName': 'ProfileByAddress',
        'variables': {
            'address': str(owner),
        },

Returns a bunch of values, one of them is userID, is it possible to query for userID as well since thats all i have when using ctx.author.id

I´m not sure if in gql you can generally query for anything or if it needs to be setup with this query in mind, like an endpoint basically

slate swan
#

i need the button to only work for the command creator

worldly solstice
#

Or even: Can i just query without passing a variable and look through id´s on the return?

south coyote
#

like this?

async def button_callback(button_inter: discord.MessageInteraction):
            button1.disabled = True
glad cradle
#

no

glad cradle
glad cradle
slate swan
glad cradle
#

so yes, you're using a View subclass

#

you're not subclassing right? you're usgin the default view classs

south coyote
#
import random
import discord
from discord import app_commands


choices = ["yes", "no"]

class Buttons(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)

    @discord.ui.button(label="Click me", style=discord.ButtonStyle.blurple, custom_id="button_yn")
    async def click(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.response.send_message(random.choice(choices))


class aclient(discord.Client):
    def __init__(self):
        super().__init__(intents=discord.Intents.default())
        self.synced = False
        self.added = False

    async def on_ready(self):
        await self.wait_until_ready()
        
        if not self.synced:
            await tree.sync(guild = discord.Object(id = '935395948727779328'))
            self.synced = True
            
        if not self.added:
            self.add_view(Buttons())
            self.added = True

        print(f"We have logged in as {self.user}")


client = aclient()
tree = app_commands.CommandTree(client)


@tree.command(name = "random", description = "random answer", guild = discord.Object(id = '935395948727779328'))
async def ticketing(interaction: discord.Interaction):
    embed = discord.Embed(title = "Think of a yes or no question then click the button!", color = discord.Colour.blue())
    await interaction.channel.send(embed = embed, view = Buttons())
    await interaction.response.send_message("Random answer button launched!", ephemeral = True)

client.run("...")
#

where does it go in there?

#

discord.ui.View.remove_item(Buttons)

glad cradle
#

what library are you using

south coyote
glad cradle
#

store the first message
msg = await interaction.channel.send(...)
then you should wait_for button_click (consider to use a custom_id so you can distinguish the button from the others buttons)
then you should edit msg removing the view, something similar, btw It would be easier changing other things in your code

slate swan
#

there's no button_click event

south coyote
#

so its not after the button sends a message

glad cradle
south coyote
#

wouldn't it be right after the random.choice(choices)

glad cradle
#

anyway I think you can use on_interaction instead of on_button_click

south coyote
#
await interaction.response.send_message(random.choice(choices))
glad cradle
south coyote
#

hmmm

glad cradle
#

and you can't pass the message sent itself as View parameter

slate swan
slate swan
#

yeah, handy

south coyote
#

so disnake

glad cradle
south coyote
#

what about if self.added = True then ....

glad cradle
#

something like this should work, although I'm not too sure now


class Buttons(discord.ui.View):
    ...

    @discord.ui.button(...)
    async def click(...):
        ...
        await interaction.edit_original_message(...)
        await interaction.response.send_message(...)

@tree.command(...)
async def ticketing(...):
    ...
    await interaction.response.response.send_message(...)
    ...
south coyote
#

oops that ticketing variable was left over from another project

glad cradle
#

or wait for interaction and check the components of the interaction, these are the ways

south coyote
#

thanks though

little lava
#

is it possible to mention a user inside discord embed?
I just tested it can tag a user, but not showing yellow highlights

slate swan
little lava
slate swan
#

Which sends message of ping and insanely deletes

#

I do it that way

silent zenith
#

i get this error in the log:
RuntimeWarning: coroutine 'playsong' was never awaited playsong(ctx)

but then when i put await playsong(ctx) i get:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object NoneType can't be used in 'await' expression

glad cradle
#

could you send your code?

vale wing
south coyote
#

how do you pick two items from a list?

#

and put them together in a print statement

#

nm

#

a_sample = random.sample(a_list, desired_number)

primal token
unkempt canyonBOT
#

random.choices(population, weights=None, *, cum_weights=None, k=1)```
Return a *k* sized list of elements chosen from the *population* with replacement. If the *population* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").

If a *weights* sequence is specified, selections are made according to the relative weights. Alternatively, if a *cum\_weights* sequence is given, the selections are made according to the cumulative weights (perhaps computed using [`itertools.accumulate()`](https://docs.python.org/3/library/itertools.html#itertools.accumulate "itertools.accumulate")). For example, the relative weights `[10, 5, 30, 5]` are equivalent to the cumulative weights `[10, 15, 45, 50]`. Internally, the relative weights are converted to cumulative weights before making selections, so supplying the cumulative weights saves work.
primal token
#

!e

import random
 
foo = ["bar", "egg", "bacon"]

print(*random.choices(foo, k=2))
unkempt canyonBOT
#

@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.

egg bar
south coyote
#

does this look right?

for i in range(1):
            await interaction.response.send_message(random.choice(dice))
#

to throw two dice

#

oh nm,

primal token
#

That only fires one time, and why 2 messages?

south coyote
#

hmmm?

#

sorry i didn't ralize you guys had answered

#
File "/home/deusopus/button1.py", line 18, in click
    await interaction.response.send_message(random.choices(*dice, k=2))
TypeError: Random.choices() takes from 2 to 3 positional arguments but 7 positional arguments (and 1 keyword-only argument) were given

primal token
#

dont unpack dice

#

Do know the function returns a list so you can use str.join if you want to make it a string

south coyote
#

okay so

#
dice = ["[ . ]", "[ : ]", "[ .: ]", "[ :: ]", "[ :.: ]", "[ ::: ]"]
#

these are the "dice"

primal token
south coyote
#

im trying to figure out how to just print two cleanly without being in a tuple

#

i was thinking of for i in range(1):

shrewd apex
#

', '.join(tuple) maybe depends on how u want it formatted

alpine cove
#

long time no see specifiy your problem

#

sup @shrewd apex asher

alpine cove
shrewd apex
#

sup

unkempt canyonBOT
#

str.join(iterable)```
Return a string which is the concatenation of the strings in *iterable*. A [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") will be raised if there are any non-string values in *iterable*, including [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. The separator between elements is the string providing this method.
alpine cove
primal token
#

And I'm pretty sure it returns a list

shrewd apex
silent zenith
# vale wing Send full traceback of second exception please

``async def playsong(ctx):
url = queue_url[0]
print(f'url: {url}')
yt = pt.YouTube(url)
t = yt.streams.filter(only_audio=True)
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
path = Path(f"Downloads/{queue[0]}.mp4")
print(path)

print(queue)
if path.is_file():
    print(queue)
    print(f"Found Song {queue[0]}")
    await ctx.send(f'**Now playing:** {queue[0]}')
    voice.play(discord.FFmpegPCMAudio(path), after=lambda x=None: playsong(ctx))
    queue.pop(0)
    queue_url.pop(0)
else:
    ctx.send(f"**Playing:** {queue[0]}.")
    print(f"Downloading song {queue[0]}")
    await ctx.send(f'**Now playing:** {queue[0]}')
    voice.play(discord.FFmpegPCMAudio(t[0].download("Downloads")), after=lambda x=None: playsong(ctx))
    queue.pop(0)
    queue_url.pop(0) ``

and the calling is this

@client.command() async def skip(ctx): voice = discord.utils.get(client.voice_clients, guild=ctx.guild) print("stopped") voice.stop() await playsong(ctx)

and this error message "/env/lib/python3.9/site-packages/discord/player.py:711: RuntimeWarning: coroutine 'playsong' was never awaited
self.after(error)" but it still works

primal token
alpine cove
#

get well

shrewd apex
#

thx thx

slate swan
#

I have a question

primal token
slate swan
#

how do I make a var for each guild

primal token
slate swan
#

so that each guild I cant run a command called $channel #channel and it will mark that channel

#

but it will work for all guilds

shrewd apex
slate swan
#
client.event
async def on_message(message):
  q = await client.process_commands(message)
  channel = message.channel
  if message.author != client.user:
      await channel.send(message.content)
      await message.delete()

like this but instead of getting channel = message.channel it will do this for all set channels in all guilds

primal token
#

You can use a database or JSON depending on the size of the data but you should use an actual database over implementing a system with JSON

slate swan
#

docs or something?

primal token
shrewd apex
#

u replied to urself pithink

primal token
#

I was following up my statement lol

shrewd apex
#

oh ic pWut

slate swan
primal token
unkempt canyonBOT
#
Not gonna happen.

No documentation found for the requested symbol.

primal token
#

!pypi aiosqlite

unkempt canyonBOT
primal token
#

guess they dont have aiosqlite in the docs command

glad cradle
#

😦

vale wing
silent zenith
vale wing
#

What kind of thing could I elaborate on

#

You just can't

#

Might want to use asyncio.run_coroutine_threadsafe()

south coyote
#

why is utils in utils.get squiggly

#
import discord
from discord import app_commands


class Buttons(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)

    @discord.ui.button(label="Click for support", style=discord.ButtonStyle.blurple, custom_id="001")
    async def click(self, interaction: discord.Interaction, button: discord.ui.Button):
        ticket = utils.get(interaction.guild.text_channels, name = f"Support-Ticket-{interaction.user.name}-{interaction.user.discriminator}")
#

utils.get is squiggly

alpine cove
#

what if two users have the same username

#

nvm

slate swan
#

*two channels have same name

alpine cove
#

I didn't properly read ur code

slate swan
#

thi a user can open multiple tickets mb

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

alpine cove
slate swan
#

i'd just store channel id with respect to user id in sqlite3 table

#

https://paste.pythondiscord.com/sotuyehufe
error-

  File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\nextcord\application_command.py", line 1542, in get_type
    raise ValueError(
ValueError: SlashCommandOption ctx of command SlashApplicationCommand create-embed <function embed_create at 0x0000021F40537430> Type `<class 'nextcord.interactions.Interaction'>` isn't a supported typehint for Application Commands.
alpine cove
slate swan
#

apps command dont have context

slate swan
#

and you dont use self in a normal function

#

its for methods

#

ValueError: SlashCommandOption interaction of command SlashApplicationCommand create-embed <function embed_create at 0x0000021E04527430> Type <class 'nextcord.interactions.Interaction'> isn't a supported typehint for Application Commands.

slate swan
#

raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In options.9: Required options must be placed before non-required options

#

ummmmm

#

all of them are false i didnt understand

#

nvm

#

forgot one it works

#

: Required options must be placed before non-required options

upbeat otter
drowsy prairie
#

Does the discode bot also have traffic when hosting?

glad cradle
#

wdym ?

drowsy prairie
#

I wonder if there will be traffic if I buy hosting and run the bot in hosting.

#

When used by the user\

slate swan
#

depends on your host

#
    if colour:
        embed.colour=int("0x" + colour, 16)
    if colour is not int:
        await interaction.response.send_message("Please provide a color with numbers! check out colorpicker.com")```

nextcord.errors.ApplicationInvokeError: Command raised an exception: ValueError: invalid literal for int() with base 16: '0xdsa'

zealous jay
#

How can I make a cog be the last to load?

upbeat otter
zealous jay
#

how

slate swan
slate swan
chrome latch
#

why my terminal is not termination when i am using ctrl+c

#

it feels something is blocking the processes

zealous jay
#
        for cog in target_dir.rglob("*.py"):
            await self.load_extension(f"cogs.{cog.parent.name}.{cog.stem}")
#

I loead them like this

south coyote
#

its frikkin saying utils not defined
File "/home/deusopus/ticketing_bot.py", line 11, in click ticket = utils.get(interaction.guild.text_channels, name = f"Support-Ticket-{interaction.user.name}-{interaction.user.discriminator}") NameError: name 'utils' is not defined

zealous jay
#

which library

upbeat otter
#

it's discord.utils btw or you from discord import utils

south coyote
#

oh duh

upbeat otter
#

the error pretty much tells everything, you can't compare an integer with a discord.Reaction object

#

depends on what starData is

#

you can typecast both of them to strings

#

and compare them that way

primal token
vale wing
#

🫦

slate swan
#

just use filter() ;-;

orchid bear
paper sluice
unkempt canyonBOT
#

Positional vs. Keyword arguments

Functions can take two different kinds of arguments. A positional argument is just the object itself. A keyword argument is a name assigned to an object.

Example

>>> print('Hello', 'world!', sep=', ')
Hello, world!

The first two strings 'Hello' and world!' are positional arguments.
The sep=', ' is a keyword argument.

Note
A keyword argument can be passed positionally in some cases.

def sum(a, b=1):
    return a + b

sum(1, b=5)
sum(1, 5) # same as above

Somtimes this is forced, in the case of the pow() function.

The reverse is also true:

>>> def foo(a, b):
...     print(a, b)
...
>>> foo(a=1, b=2)
1 2
>>> foo(b=1, a=2)
2 1

More info
Keyword only arguments
Positional only arguments
!tags param-arg (Parameters vs. Arguments)

timid pawn
#

hello guys how do icreate an on_schedule_event_create() listener using the discord.Clients

orchid bear
paper sluice
slate swan
#

i need the button to only work for the command creator

proud apex
#

is it possible to make temporary buffs? For example + 15% to money from work for 2 hours?

proud apex
#

but as?

placid skiff
#

depends on you, you can do it with asyncio (the same thing is done with temp bans for example), create your own event system, or create a discord event, they're made through the dispatcher but it is not meant to be used so there aren't examples and there is no documentation about the dispatcher, yet you can look through the source code of d.py and look at how they're made

shrewd apex
#

(await cursor.fetchall())[0]

glad cradle
#

what you're trying to achieve

primal token
#

The logic doesnt make sense? How can a Reaction object be larger or equal than a number?

#

Yes? The attribute already returns a string?

#

!d discord.Message.content

unkempt canyonBOT
cosmic agate
#

Command raised an exception: TypeError: Type must meet VoiceProtocol abstract base class.

glad cradle
#

you can't interpret a Reaction as a number

primal token
#

I'm not sure what you want to achieve

cosmic agate
# cosmic agate Command raised an exception: TypeError: Type must meet VoiceProtocol abstract ba...
@bot.command(aliases=["pl"])
async def play(ctx: commands.Context, *, search: wavelink.YouTubeTrack):
    if not ctx.voice_client:
        vc: wavelink.Player = await ctx.author.voice.channel.connect(cls=wavelink.Player)
        await vc.play(search)
        embed = nextcord.Embed(title=f"**{search.title}**", description=f"> Now Playing: {search.title}\n> Duration: {search.duration}\n> Author:  {search.author}", color=nextcord.Colour.random())
        embed.set_footer(text="noice")
        await ctx.reply(embed=embed)
    elif not getattr(ctx.author.voice, "channel", None):
        return await ctx.send("you have to be in voice channel!")
    else:
        vc: wavelink.Player = ctx.voice_client

    if vc.queue.is_empty and not vc.is_playing():
        await vc.play(search)
        embe = nextcord.Embed(description=f"> Now Playing: {search.title}\n> duration: {search.duration}\n> author:  {search.author}", color=nextcord.Colour.random())
        embe.set_footer(text="noice")
        await ctx.send(embed=embe)
cloud dawn
#

!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)
cosmic agate
#

ok sar

primal token
#

ytld😳

cosmic agate
#

💀

glad cradle
#

hi noid

primal token
#

hi snipy✌️

glad cradle
#

opened 6 issues pithink

primal token
#

let me view them

glad cradle
#

most of them are the same issue

#

DisnakeDev/disnake#839
DisnakeDev/disnake#845
DisnakeDev/disnake#846

glad cradle
#

Rapptz/discord.py#9039
nextcord/nextcord#882
nextcord/nextcord#883

glad cradle
#

the voice implementation is really bugged

primal token
#

Yeah just saw them, i cant really comment about them as they're mostly about vc

cloud dawn
#

There is a way to solve this but people don't bother debugging.

glad cradle
#

I think that if I try to test other classes I would probably find other bugs, it is something related to how the Threads that play the audio are handled

upbeat otter
glad cradle
primal token
#

👀

primal token
upbeat otter
#

yeah thanks for your concern

#

wait are you okimii??

#

I mean, okimii did that type of stuff nobody wanted, so....you changed your name?

primal token
#

no, okimii left his socials a while ago

glad cradle
#

btw I'm working on DisnakeDev/disnake#839 rn

lament depotBOT
glad cradle
#

DisnakeDev/disnake#837 if you want to take a look (mostly are changelog entry and docs but yeah)

quiet dew
#

How i can make a command show me in how many servers the bot and how many users and only owner the bot can use it

sick birch
cloud dawn
#

is_owner decorator for owner bot only

cloud dawn
sick birch
#

i oop

primal token
drifting cypress
#

class MyView(discord.ui.View,discord.Interaction):
    @discord.ui.button(label="Click me!", style=discord.ButtonStyle.primary)

    async def button_callback(self,button,interaction):
        await interaction.response.send_message("You clicked the button!")
    @discord.ui.button(label="Button 2", row=1, style=discord.ButtonStyle.primary)
    async def second_button_callback(self,button,interaction):#
        await interaction.response.send_message("You pressed me!")

@client.tree.command(name="msg_only", description="___")
async def _ping(interaction: discord.Interaction) -> None:
    await interaction.response.send_message("pong",view=MyView())#,ephemeral=True

i'm getting this error:
AttributeError: 'Button' object has no attribute 'response'
how can i fix it ?
i'm still new with this API :/

primal token
#

You have your arguments in your buttons switched around

slate swan
south coyote
#

is there a way to say hello to members when they enter a certain channel?

sick birch
primal token
#

you're bad

south coyote
#

get a room you two

sick birch
primal token
sick birch
primal token
#

😳

mighty pilot
honest shoal
#

*yro’ue

keen vault
#

Hi, not sure if this is the right place to ask but, when I tried to install discord.py it told me that pip wasn't found. Someone sent me this link to download but I'm a bit confused of what to do https://bootstrap.pypa.io/get-pip.py

cloud dawn
#

py -m pip install discord.py

keen vault
slate swan
cloud dawn
#

And what command did you ran?

keen vault
#

py -m pip install discord.py

keen vault
slate swan
#

or it will open the file in the browseer and you can use ctrl+s to save the file

keen vault
#

uhh it didn't do any of that?

slate swan
#

did it not start an automatic download?

keen vault
#

no

slate swan
#

what browser are you using?

keen vault
#

oh right I clicked

#

ctrl+s

#

does it matter where I save it?

slate swan
#

well you'll have to open that directory in command prompt thats all

#

doesnt really matter yes

keen vault
#

Okay I've downloaded it

#

alright pip is downloaded

slate swan
#

now open your command prompt and type cd "path where you placed the download" and then py get-pip.py thats all!

keen vault
cloud dawn
#

Or just double click on the file

slate swan
#

yeah thats an option as well 3KSFdance

keen vault
slate swan
keen vault
#

But it worked without doing that

slate swan
keen vault
#

oh

#

okay, thanks for helping

cloud dawn
#

Sarth makes everything a tiny bit more complicated than needed.

#

It's a trait, honestly.

keen vault
#

As long as it works at the end, it's fine

slate swan
#

for me it will just open the file in the default text editor

cloud dawn
#

Sounds like an OS issue.

slate swan
#

literally every non-windows os

cloud dawn
#

I know

keen vault
#

Hi again, I'm doing a command but I have a different layout which has multiple lines. What would I need to add to make it a separate line?

slate swan
keen vault
#

Thank you

#

How do I separate links?

verbal monolith
#

yoo whats the equivalent of a server/guild in discord py? so i.e

username = str(message.author).split('#')[0]
    user_message = str(message.content)
    channel = str(message.channel.name)
    server = str(message.guild.name) # this obviously isnt guild, so what is it?
    print(f'{username}: {user_message} (#{channel} in {server} )')```
keen vault
slate swan
keen vault
#

I've seppated lines with \

#

I think I know why

#

when I tested other commands, and now deleted them, they still work for some reason

slate swan
#

you didnt restart your code

keen vault
#

I did
ctrl + s
and then
python main.py

#

is that enough?

verbal monolith
#

also why doesnt this work? im trying to be able to send discord messages from the console

#
    if message.channel.name == 'alabama' or message.channel.name == 'ai':
        if message.content.lower() == 'Nerf Blaster 420!':
            custom_message = input('Enter Your Text: ')
            await message.channel.send(custom_message)
            return```
slate swan
primal token
keen vault
slate swan
verbal monolith
slate swan
keen vault
#

how?

slate swan
#

ctrl+c in terminal stops the process

slate swan
unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

primal token
verbal monolith
#

hold on

primal token
keen vault
verbal monolith
#

i want it to say pellko!: Raghh (posted in {channel_name} in {server})

slate swan
verbal monolith
#

so i.e pellko!: Raghh (posted in #ai in Python Discord)

slate swan
#

ah

keen vault
#

im doing ctrl c it's not working

slate swan
#

show a screenshot

#

you should be doing it in the process where you started the bot

keen vault
#

I do ctrl + c, type python main.py again and the command is still working

verbal monolith
#

nvm i did it

#
    username = str(message.author).split('#')[0]
    user_message = str(message.content)
    channel = str(message.channel.name)
    guild = str(message.guild.name)
    print(f'{username}: {user_message} (posted in #{channel} in {guild})')
primal token
#

Quite unpythonic

white citrus
#
f"> **Category:** {<#{s_channel.category_id}> if {s_channel_category_id} else 'No Category'}\n"```

Please help
cloud dawn
primal token
#

ok?

keen vault
#

@slate swan can u help?

vale wing
#

Too many str to str casts

slate swan
vale wing
#

For what

slate swan
#

they have multiple bot processes running and are unable to stop them

vale wing
#

Sorry that wasn't a response to you, that was a continuation of my previous phrase

#

🤗

slate swan
#

owo

winged linden
#

Hey guys

#

when I run my bot I get an error called improper token

vale wing
#

Bad token 🤗

winged linden
#

I've been resetting the token and repasting it but it still gives me the error

vale wing
#

Could you show your code

winged linden
#

TOKEN = "inserttoken"

bot.run(TOKEN)
#

Or do you need all of the code

vale wing
#

Seems legit

#

Do you redefine TOKEN anywhere

winged linden
#

nope

vale wing
#

Now could you show where you bring the token from on dev portal

keen vault
vale wing
#

Screenshot

vale wing
winged linden
slate swan
#

or hot reload if you use cogs

keen vault
winged linden
#

anyone got a solution to my issue?

winged linden
#

this error has also shown up

#

seems like im not authorised to use my own bot>

winged coral
#

Show the full traceback not just the last line

#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

slate swan
winged linden
#

cring username

winged coral
#

Look at the last line

#

It tells you the exact problem

hollow gazelle
#

i need help adding a point counter in my command where u can do !win @hollow gazelle and it adds 10 points to the file with the poiints they already have

winged linden
#

token is definitely correct

#

ive reset it multiple times and copy and pasted

hollow gazelle
winged linden
#

its literally line after line aswell

#

so nothing is redefining it

winged coral
#

I don't know how to tell you but it just simply can't be the right token

winged linden
#

it has to be

#

ill reset it again

hollow gazelle
#

or he could just do py bot.run("token") insted of making it complicated or even just make a config

winged linden
#

ill try that

winged coral
#

Once you've reset it, could you show us the uncensored code with the previous token? Id like to see if it's in the right format

winged linden
#

sure

hollow gazelle
#

looks good to me

winged coral
#

Seems alright, weird it's giving 401

winged linden
hollow gazelle
#

wait

#

aint 401 rait limit

winged linden
#

even doing the bot.run("token")

#

is it rate limiting me?

#

breh

winged coral
#

I don't think it's a rate limit

hollow gazelle
#

it might be

winged linden
#

i dont think so

winged coral
#

It would give you a 429

hollow gazelle
#

wait no rate limit is 428

winged linden
#

im not getting rate limited on site either

hollow gazelle
#

429 mb

winged linden
#

401 is unauthorised

hollow gazelle
#

what are u trying to use the bot on

#

is it somthing against tos

#

for discord

winged linden
#

no

#

im just trying to run it with python

#

its literally just a normal discord bot 😭

#

i just wanna test my code kekw

cloud dawn
#

Has it ever ran?

winged linden
#

no

#

brand new

cloud dawn
#

Would you mind sharing the whole code?

jovial cove
#

why don't you just put the token within the bot.run function?

#

instead of making a variable?

winged linden
#
import discord, traceback, random
from datetime import datetime
from discord.ext import commands


#bot configuration

prefix = "-"
bot = commands.Bot(command_prefix=prefix)
color = 0xc63939
bot.remove_command('help')
bot.donation_log_channel = 1037397123123126363 # enter the id of where you want donation logs to be sent to
bot.donationrole = 1037392038594891807
bot.suggestion_channel = 1037426350585282723
#enter the id of where you want suggestions to be sent to

@bot.event
async def on_ready():
    print(f"{bot.user} is ready")

@bot.command()
async def help(ctx):
    embed=discord.Embed(title="Commands",description="{prefix}embed [#channel] - Creates a custom embed\n{prefix}donate [@user] [donation] - Logs donations made",timestamp=datetime.utcnow(),color=color)
    embed.set_footer(text="Developed by Fiery")
    await ctx.send(embed=embed)

@bot.command()
@commands.has_role(bot.donationrole)
async def donate(ctx, member:discord.Member, *, donation):
    channel = ctx.guild.get_channel(bot.donation_log_channel)
    embed=discord.Embed(title="New Donation",description=f"Discord: {member}\nDonation: {donation}",color=color,timestamp=datetime.utcnow())
    embed.set_footer(text="Developed by Fiery#6858")
    await channel.send(embed=embed)
    await ctx.send(f"{ctx.author.mention}, donation log successful!")

#

did that still didnt work

cloud dawn
#

You don't have any intents.

winged linden
#

ofc the bot run bit is under

#

i kept getting errors when defining intents

#

so i removed it

cloud dawn
#

Did you use .all()

winged linden
#
bot = commands.Bot(command_prefix=prefix,intents=discord.Intents.all())
#

that was how i defined intents

cloud dawn
#

!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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.

winged linden
#

damn they changed it?

cloud dawn
#

It has been like this for years, all is just defining that you want all intents but since a while you can't enable them all since some are privileged.

winged linden
#

tbf i havent coded in years

#

discord bot wise

cloud dawn
#

content isn't a valid intent

winged linden
#

intents.message then?

#

MESSAGE CONTENT INTENT
Required for your bot to recei

cloud dawn
#

!d discord.Intents

unkempt canyonBOT
#

class discord.Intents(value=0, **kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client").

New in version 1.5.
winged linden
#

eh so is it intents.message or

cloud dawn
#

The blue title is an URL, there you can find all info about intents.

winged linden
#

o

#

ill just give the bot the administrator intent too

winged linden
#

wait

#

im an idiot oh my goodness

#

it woould be like intents.message.administrator

#

no

cloud dawn
#

What?

winged linden
#

intents.message.channel

#

?

#

clearly bad programmer here

cloud dawn
#

discord.Intents is a class with attributes and 3 methods. The attributes are by default False, if a attribute is set to True that intent is enabled.

winged linden
#

yes but im trying to find the names of the attributes

#

to enable the intent

vocal snow
#

!d discord.Intents

unkempt canyonBOT
#

class discord.Intents(value=0, **kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client").

New in version 1.5.
vocal snow
#

(click the title)

winged linden
#

message_content

cloud dawn
#

On the left there is a whole list of attributes.

winged linden
#

thank you

cloud dawn
#

So ```py
intents = Intents.default()
intents.members = True
intents.message_content = True

upbeat tartan
#

Yes

winged linden
#

yeah

#

pov your an idiot

#

kekw i didnt even define intents

cloud dawn
#

from discord import Intents

winged linden
#

ik

cloud dawn
winged linden
#

i forgor to do it

#

lol

primal token
# jovial cove instead of making a variable?

You can use a variable from another module, e.g a config module and not on your main module to avoid leaking credentials of any kind, you can also use toml or json, really anything, do note some platforms like replit use envs for securing credentials

keen vault
#

can someone help?

cloud dawn
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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.

winged linden
sick birch
#

Capital i

winged linden
#

did that

cloud dawn
winged linden
#

i changed it cuz i thought it was lowercase

sick birch
#

It's not

winged linden
#

didnt work with capital too

sick birch
#

!d discord.Intents

unkempt canyonBOT
#

class discord.Intents(value=0, **kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client").

New in version 1.5.
cloud dawn
#

😂

viral dock
#

Does someone know a guide in words (bcs I wanna learn something, not copy something) to make a discord bot?

sick birch
#

If it didn't work with capital I it's a different error

#

And we'd like to see that different error

keen vault
winged linden
sick birch
#

well that's not good

cloud dawn
winged linden
sick birch
#

Just use discord.Intents instead of trying to import

#

It pollutes your namespace anyway

winged linden
#

wdym

#

as in

#

discord.intents.members

sick birch
#

You don't have to import it

keen vault
sick birch
#

You'd just do something like discord.Intents.default() to get default intents

winged linden
#

ah I see

cloud dawn
winged linden
#

mother fu

sick birch
winged linden
#

doubt it

keen vault
winged linden
sick birch
#

It shouldn't be doing that unless you've got a broken install

sick birch
winged linden
#

my install is very old

winged linden
slate swan
#

x can be any number there

winged linden
#

bro what

#

scammed

slate swan
#

you either don't have discord.py installed at all, or have multiple versions of python

winged linden
#

prolly multiple

#

ill reinstall

sick birch
#

!minusmpip

unkempt canyonBOT
#
Install packages with `python -m pip`

When trying to install a package via pip, it's recommended to invoke pip as a module: python -m pip install your_package.

Why would we use python -m pip instead of pip?
Invoking pip as a module ensures you know which pip you're using. This is helpful if you have multiple Python versions. You always know which Python version you're installing packages to.

Note
The exact python command you invoke can vary. It may be python3 or py, ensure it's correct for your system.

sick birch
#

Using plain "pip" is not recommended

winged linden
#

i uninstalled the lower version of python anyway

sick birch
#

Specify which python version you're using with pip

winged linden
#

but alr

#

lets try this again

keen vault
#

can someone help me, it shows an error with intents

winged linden
#

FINALLY ITS WORKING

#

bot is online

winged linden
#

Thanks for the help guys

sick birch
#

Which could that be?

keen vault
cloud dawn
sick birch
#

Guessed right my friend

slate swan
#

so i wanna do that a member needs to setup a role

#

and he can choose any role

sick birch
slate swan
#

how do i do that

sick birch
#

!intents @keen vault

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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.

winged linden
#

Does \n go inside or outside speech marks

sick birch
#

Inside

winged linden
#

Alr

cloud dawn
#

My new favorite way of calling strings.

keen vault
sick birch
#

Again.. what is an error?

white citrus
#

How can i get all servers and invites to it from a bot in discord.py

slate swan
#

so i wanna do that a member needs to setup a role
and he can choose any role how do i do that?

verbal monolith
#
    except socket.error, msg:
        print("|[Connection Failed]         |")```
why doesnt this work in 3.11?
keen vault
white citrus
cloud dawn
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

sick birch
cloud dawn
#

Did they remove !tb ..?

sick birch
#

What's the new code look like now?

keen vault
slate swan
#

so i wanna do that a member needs to setup a role
and he can choose any role how do i do that?

sick birch
#

You just need one

white citrus
cloud dawn
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)
sick birch
unkempt canyonBOT
#
Not in a million years.

No documentation found for the requested symbol.

sick birch
#

Shoot

#

!d discord.TextChannel.create_invite

unkempt canyonBOT
#

await create_invite(*, reason=None, max_age=0, max_uses=0, temporary=False, unique=True, target_type=None, target_user=None, target_application_id=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates an instant invite from a text or voice channel.

You must have [`create_instant_invite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.create_instant_invite "discord.Permissions.create_instant_invite") to do this.
sick birch
#

There

verbal monolith
unkempt canyonBOT
#
Nope.

No documentation found for the requested symbol.

sick birch
#

Man this chat really turned into just !d

cloud dawn
sick birch
#

Amazing how many problems can be solved by reading the documentation

verbal monolith
cloud dawn
slate swan
cloud dawn
slate swan
#

how do i do the role mention and keep that thing

white citrus
# sick birch There

Is it right?

    embed = discord.Embed(description="Not important")
    for server in bot.guilds:
        inv = await server.create_invite(max_age=1, max_uses=1)
        embed.add_field(name=server, value=inv)
    
    await ctx.send(embed=embed)```
cloud dawn
verbal monolith
white citrus
cloud dawn
sick birch
#

I must admit getting the invites for all of the servers your bot is in is.. strange

white citrus
slate swan
#
class MyButton(nextcord.ui.View):
    def __init__(self):
        super().__init__()
        self.value = None
    
    @nextcord.ui.button(label="Claim", style=nextcord.ButtonStyle.green, emoji=":NoaOkay:")
    async def my_button(self, interaction: nextcord.Interaction, button: nextcord.ui.Button):
        if interaction.permissions.manage_messages == False:
          return await interaction.response.send_message(content="**You Cant Claim! Only Staff Can!**", ephemeral=True)
        button.disabled = True 
        button.label = f"Claimed by - {interaction.user.name}#{interaction.user.discriminator}" 
        await interaction.response.edit_message(view=self)

@bot.command()
async def helpmesetup(ctx, member: nextcord.Member):
    


@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
       embed = '**You have cooldown ! Please use this command again in __{:.2f}__s**'.format(error.retry_after)
       await ctx.send(embed)
    else:
        raise error

@bot.command(aliases=["H"])
@commands.cooldown(1,30,commands.BucketType.user)
async def h(ctx, *,message='No Reason ! '):
    check = ctx.author.voice
    if check is None:
      voice = f'The User Is Not Connected To A Voice ! '
    else:
      voice = ctx.author.voice.channel.mention
    emeb12233 = nextcord.Embed(title='User:',description=f'{ctx.author.mention} Needs Help  ',color=0x6c97c5)
    emeb12233.add_field(name="Reason:", value=f'{message}', inline = False)
    emeb12233.add_field(name="Voice:", value=voice, inline = False)
    emeb12233.set_author(icon_url=ctx.author.avatar, name=ctx.author.name + "#" + ctx.author.discriminator,)
    emeb12233.set_thumbnail(url=ctx.author.avatar)
    await ctx.send(f"{staff_role}", embed=emeb12233, view=MyButton())

@bot.command()
async def gfcxfsedsa(ctx):
    view = MyButton()
    await ctx.send(view=view)```
keen vault
#

How would you make embed welcome messages?

white citrus
#

The Bot is only used by old friends @cloud dawn not Global

slate swan
unkempt canyonBOT
#
Not gonna happen.

No documentation found for the requested symbol.

cloud dawn
#

Add to every command that the bot is shutting down in x amount of days.

slate swan
#

!d discord.on_member_join

unkempt canyonBOT
#

discord.on_member_join(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") joins a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
slate swan
#

and then making an embed w that

white citrus
cloud dawn
#

Then send a message from the bot to all general channels.

shell wing
#

how can i make an embed out of modal ?
also how to make it send the response in a channel ??

cloud dawn
#

Not a lot of experience with modals but you can use defer.

#

!d discord.ui.Modal.on_submit

unkempt canyonBOT
#

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

Called when the modal is submitted.
cloud dawn
#

Seems like a viable method

shell wing
#
 async def on_submit(self, interaction: discord.Interaction):
        await interaction.response.send_message(f'Your application was submitted successfully, {interaction.user.mention}!', ephemeral=True)
``` i have this on my `on_submit` rn
slate swan
#

does anyone knows why it doesnt let my bot be public

#

like noit everyone can add it

cloud dawn
#

Wdym?

slate swan
#

only i can add the bot and not everyone

#

like it should have the button

cloud dawn
#

That gets added manually.

winged linden
#
@bot.command()
async def ping(ctx,self):
    await ctx.send(f'Pong{round(self.bot.latency *1000)}) ms')
slate swan
winged linden
#
  File "C:\Users\OneDrive\Desktop\AtomProjects\HyperionFund Discord Bot\main.py", line 136, in ping
    await ctx.send(f'Pong{round(self.bot.latency *1000)}) ms')
AttributeError: 'str' object has no attribute 'bot'```
#

lil confused on what im doing wrong

slate swan
#

show command

cloud dawn
slate swan
slate swan
#

why u passing self

#

also after ctx.

#

ur bot is one file yea?

winged linden
#

bot is one file yeah

slate swan
#

yea u don't need self

winged linden
#

is it also just bot.latency

slate swan
#

yup

cloud dawn
winged linden
#

yeah figured it out kekw

#

whats the .2 for thought

cloud dawn
#

Faster way of rounding in a string format.

winged linden
#

ah i see

#

got it to work

winged linden
#

also the full text was run it back

cloud dawn
winged linden
#
@bot.command()
async def suggest(ctx, suggestion):
    channel = ctx.guild.get_channel(bot.suggestion_channel)
    embed=discord.Embed(title=f"Suggestion from {ctx.author.mention}", description=f"{suggestion}", color=color,timestamp=datetime.utcnow()
    await channel.send(embed=embed)
    await ctx.send(f"{ctx.author.mention}, suggestion successfully sent!")
#

how do I get suggestion to be the reminder of the text after -suggest

#

remainder

#

rather than just one word

#

also how would I use the authors username rather than their id

hollow gazelle
winged linden
cloud dawn
hollow gazelle
#

Like 5 mins I’ll show I

hollow gazelle
winged linden
#

Ah not in the title

cloud dawn
#

Generally don't mention in embed's since Discord mobile doesn't really format that really well.

winged linden
#

how would I get it to say Fiery#8372

cloud dawn
winged linden
#

str

#

also wouldnt it be ```

str{ctx.author}```

#

or do normal brackets work the same

keen vault
#

someone help please again

cloud dawn
winged linden
#

because ive currently got it in f" str{ctx.author}"

#

really thats how i was taught to do it in discord.py lol

#

its all over my code its kinda ugly ngl lemonpeek

cloud dawn
#

That's also fine, but then you don't need str

winged linden
#

ight

winged linden
#

currently its only taking the first word

cloud dawn
#

I have no clue what you mean.

winged linden
#

ok so the command is like -suggest run it back

slate swan
winged linden
#

and currently in the embed its only taking the first word run

cloud dawn
slate swan
winged linden
#

ah the star thx

#

i was thinking asterisk

keen vault
#

theres still a lot of errors tho

slate swan
#

send

keen vault
slate swan
#

on channel, what did u do

keen vault
#

wdym

slate swan
#

like channel = bot.get_channel(id)

keen vault
#

uh I didnt do that

slate swan
#

u need to

#

w the id of the welcome room

keen vault
#

does it matter where

slate swan
#

its sending the welcome message]

slate swan
keen vault
slate swan
#

like its sending there the welcome msg w the original discord welcome msg

#

and if u want it to be dif then do that

keen vault
#

okay done

#

anything else?

slate swan
#

try to run the code

#

and show the error

keen vault
south coyote
slate swan
slate swan
#

instead of that

keen vault
#

like this?

slate swan
#
  • means that it imports all the stuff from easy pil
slate swan
#

try to run the code

keen vault
#

same errors

slate swan
#

what imports do u have

keen vault
slate swan
#

and u did pip install easy_pil

keen vault
#

yes

slate swan
#

from easy_pil import Editor

#

try adding that too

keen vault
#

same

#

errors

slate swan
#

send the code

#

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

slate swan
#

like that

keen vault
#
@bot.event
async def on_member_join(member):
    channel = bot.get_channel(1035299325720408230)
    
    background = Editor("pexels-quintin-gellar-313782.jpg")
    profile_image = await load_image_async(str(member.display_avatar.url))

    profile = Editor(profile_image).resize((150, 150)).circle_image()
    poppins = Font.poppins(size=50, variant="bold")

    poppins_small = Font.poppins(size=20, variant="light")

    background.paste(profile, (325, 90))
    background.ellipse((325, 90), 150, 150, outline="white",stroke_width=5)

    background.text((400, 260), f"Dobrodošao/la na {member.guild.name}", color="white", font=poppins, align="center")
    background.text((400, 325), f"{member.name}#{member.discriminator}", color="white", font=poppins_small, align="center")

    file = File(fp=background.image_bytes, filename="pexels-quintin-gellar-313782.jpg")
    await channel.send("Dobrodošao/la {member.mention}!")
    await channel.send(file=file)
slate swan
#
@bot.event
async def on_member_join(member):
    channel = bot.get_channel(1035299325720408230)

    background = Editor("pexels-quintin-gellar-313782.jpg")
    profile_image = await load_image_async(str(member.display_avatar.url))

    profile = Editor(profile_image).resize((200, 200)).circle_image()
    poppins = Font.poppins(size=50, variant="bold")

    poppins_small = Font.poppins(size=20, variant="light")

    background.paste(profile, (320, 60))
    background.ellipse((320, 60), 200, 200, outline="white",stroke_width=5)
    
    background.text((414, 320), f"Dobrodošao/la na {member.guild.name}", color="white", font=poppins_small, align="center")
    background.text((414, 260), f"{member.name}#{member.discriminator}", color="white", font=poppins, align="center")
    file = File(fp=background.image_bytes, filename="pexels-quintin-gellar-313782.jpg")
    await channel.send(f"Dobrodošao/la {member.mention}!", file=file)```
#

@keen vault try that

keen vault
#

same errors

slate swan
#

is that the only command u have?

keen vault
#

i have 2

slate swan
#

can u send the whole code

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

topaz helm
#

Does anyone have a command for the avatar to go please?

#

Or server stats or user info?

#

Have you? I saw that you are good at it @slate swan

winged linden
#
end = datetime.datetime.utcnow() + datetime.timedelta(seconds=time)

is this correct?

#

datetime.datetime is giving an error

#

but if i take away the first datetime then datetime is no longer red

slate swan
slate swan
winged linden
#

just datetime?

slate swan
winged linden
#

im now getting an issue with timedelta

slate swan
#

But imports

from datetime import datetime, timedelta
discord.utils.utcnow()+timedelta(seconds=time)
winged linden
#

o

winged linden
#

so end = discord.utils.utcnow()+timedelta(seconds=time)

winged linden
#

nice its working

#

I got confused on my giveaway bot code so i had to look up a working one and work from it

keen vault
#

@slate swan will send u in a bit sorry

slate swan
slate swan
winged linden
#

thanks 😄

slate swan
#

:)

winged linden
#
users = await new_message.reactions[0].users().flatten()

#

im ngl i dont even know what flatten does

torn sail
winged linden
#

ah

torn sail
#

It’s now users = [user async for user in users()]

#

Cause the users method now returns an async gen

winged linden
#

little confused on what that does

#

do i just paste that in place of my new code

torn sail
#

Do u know list comprehension?

winged linden
#

i do

#

user for user in users isnt that just the same thing in itself

torn sail
#

It’s a bit different in generators

#

The values aren’t there until you ask for them

winged linden
#
users = await new_message.reactions[0].user async for user in users()
winged linden
torn sail
winged linden
#

Ohhh

#

I get it now

#

are the square brackets needed?

torn sail
#

Yes

winged linden
#

alr

hollow gazelle
#
@bot.command()
@commands.has_any_role(964177601528725587)
async def win(ctx):
        embed = discord.Embed(title="**5 PTS Added**", description="Your team has won `5 points`", color=0xfc0303)
        await ctx.send(embed=embed)
        ctx.send``` who can help me make it so when u @ the person jt adds points into a txt for them
keen vault
#

@slate swan ive sent u a private message

winged linden
#
@tree.command(name = "help", description = "Sends a list of Commands", guild = discord.Object(id = bot.guild_id))
async def self(ctx):
        embed=discord.Embed(title="Commands",description="Staff Only Commands: \n **-embed [#channel]** - Creates a custom embed \n **-donate [@user] [donation]** - Logs donations made \n **-giveaway** - Starts a brand new giveaway (Needs Giveaway Host Role) \n **-reroll [channel] [giveawayID]** - rerolls the specified giveaway (Needs Giveaway Host Role) \n \n Fun Commands: \n **-8ball [Question]** - Ask the magic 8ball a Question! \n **-suggest [suggestion]** - Posts your suggestion in the suggestion channel \n **-ping** - shows the current ping of the bot",timestamp=datetime.utcnow(),color=color)
        embed.set_footer(text="Developed by Fiery")
        await ctx.send(embed=embed)
#

Im trying to convert all my commands to slash commands at the request of the admin

#

But im getting this error

#

nvm got it working

hollow gazelle
#

was botta

winged linden
#

if so how would i go about doing that

hollow gazelle
#

who can dm me and help me with somthing if they have time

young pendant
#

Hey, when I'm running this code, the bot only creates the slash-commands with the number 2 at the end and not the commands with the number 1, can someone help me?
Code: https://paste.pythondiscord.com/zegurohaca

glad cradle
winged linden
#

just because its a slash command doesnt mean i cant use the normal command functions is what i realised

young pendant
#

What do you mean by that? you need the code?

#

or what?

glad cradle
#

where is the function, at what line

young pendant
#

170 the bot creates the commands with nr.1 at the end

glad cradle
#

nvm found the problem

young pendant
#

ah ok

glad cradle
#

you're creating two client object but running just one of them, basically you're overriding the old client object with a new one, fresh and empty (without app commands etc) so that's why all your nr1 functions aren't getting registered

#

btw I don't understand why you redefine the class and client

young pendant
#

how do I get it to work?

glad cradle
#

what's the point of creating a new client object and redefine the client subclass?

glad cradle
young pendant
#

is it ok, if you show me what to do, I'm a little confused rn

#

@glad cradle

young pendant
#

@hollow agate are, you there?

winged linden
#

Hi guys so im converting my commands to slash commands

#
@tree.command(name = "giveaway", description = "Create a giveaway", guild = discord.Object(id = bot.guild_id))
@commands.has_role("Giveaway Host")
async def giveaway(interaction: discord.Interaction, channel: discord.TextChannel, time: int, *, prize: str):
    # Giveaway command requires the user to have a "Giveaway Host" role to function properly

    try:
        channel_id = int(channel)
    except:
        await interaction.response.send_message(f'You mentioned the channel wrong. This is how you do it: {interaction.channel.mention}')
        return

    channel = bot.get_channel(channel_id)


    #Got a little confused to I may have borrowed some code from online lol


    await interaction.response.send_message(f'The giveaway for {prize} will begin soon.\n Please go to {channel.mention}, the giveaway will end in {time} seconds.')
#

This is my code currently but when I put the channel in correctly I get the error that I mentioned it wrong

#

Can anyone help me with this logic error

young pendant
#

like that

#

sorry

#

my mistake

mighty pilot
#

Oh nvm there is no error because you have the except

#

Channel will give you the channel object. Are you just trying to make a post in it later in the code?

#

If all you're doing is throwing a post in it, I'd get rid of a few lines and just channel.send(message goes here)

mighty pilot
#

Not if they're giving you the channel in the slash command, you shouldn't

young pendant
#

@mighty pilot can you help me?
The bot only creates the commands with nr.2 at the end because I have
class Aclient(discord.Client):
client = Aclient()
2 times
Can you help me to fix this? https://paste.pythondiscord.com/ipusivonul.py

winged linden
mighty pilot
winged linden
mighty pilot
winged linden
#

Yes

torn sail
#

!d discord.app_commands.describe

unkempt canyonBOT
#

@discord.app_commands.describe(**parameters)```
Describes the given parameters by their name using the key of the keyword argument as the name.

Example:

```py
@app_commands.command(description='Bans a member')
@app_commands.describe(member='the member to ban')
async def ban(interaction: discord.Interaction, member: discord.Member):
    await interaction.response.send_message(f'Banned {member}')
```  Alternatively, you can describe parameters using Google, Sphinx, or Numpy style docstrings...
mighty pilot
#

Yea that's how

#

I need to learn how to use that bot lol

winged linden
#

so it would be @strange knoll_commands.describe(time="Entertime")

#

sorry for ping random dude

mighty pilot
#

Yea whatever is in parentheses will be the description

#

Of the given subcommand

mighty pilot
young pendant
#

yeah, but I dont know how to fix it 💀

winged linden
mighty pilot
winged linden
#

Oh

#

but I havent defined the parameters there yet

mighty pilot
#

Just like the example in the embed up there

winged linden
#

i guess

winged linden
mighty pilot
#

What you mean