#discord-bots

1 messages · Page 500 of 1

cloud dawn
gloomy coral
#

help pls

#

@little ether

cloud dawn
#

!d discord.VoiceState.self_video

unkempt canyonBOT
sick talon
cloud dawn
sick talon
gloomy coral
#

he just did

cloud dawn
gloomy coral
#

click on link

sick talon
little ether
gloomy coral
#

yay he is back

#

wait what

#

i was trying in dms @little ether

little ether
gloomy coral
#

cool

slate swan
gloomy coral
#

ohh

slate swan
#

You can remove only the bot's reactions

boreal ravine
gloomy coral
#

i saw tht now 😦

astral musk
#

I have a looped function that used to be in main but I've moved it to a Cog file for organization. I used to func.start() in main as well.

async def startup_code():
    func.start()
    # Other stuff


bot.loop.create_task(startup_code())

bot.run(token)

I'm wondering how I should start func now that it's in a cog file.

cloud dawn
#

You could just import the cog

astral musk
# cloud dawn You could just import the cog
from cogs import cog_file_name

async def startup_code():
    cog_file_name.func.start()
    # Other stuff


bot.loop.create_task(startup_code())

bot.run(token)

Do you mean like this?

boreal ravine
#

They don't

#

DMs don't even have any sort of permissions?

cloud dawn
#

hoping this guy doesn't for loop his dir to load the cogs

boreal ravine
#

I meant that they cant remove reactions..

astral musk
cloud dawn
#

I dunno i don't know your code

maiden fable
#

What happened?

astral musk
astral musk
maiden fable
#

I don't think so

karmic totem
cloud dawn
#

Some think it's great but i think it's not so great, imo there are more cons than pros

astral musk
karmic totem
#
- 'NoneType' object has no attribute 'send'```
astral musk
karmic totem
#

that is what I got.

maiden fable
cloud dawn
#

Personally if you use any kind of __*__ file you can't use this method, yes i tried to exclude it in the code. All cogs have to be in one place unless you want to join other dirs. And it's just pretty unclear for others what is happening.

As for pros it's easy for beginners, for many cogs you don't have to type the path.

astral musk
maiden fable
#

Seems like member is returning None

#

Cz of a wrong ID or the member not being in the cache (if they using get_member)

karmic totem
maiden fable
#

@karmic totem can I see your code?

astral musk
karmic totem
astral musk
cloud dawn
#

relp.it is not that bad for 1 servers it's just that most people that use it don't have a lot of coding experience some even having bots of 5-8k lines in one repl.it file. yes it laggs

astral musk
#

The fact that it doesn't show the full error message is the biggest red flag to me.

cloud dawn
karmic totem
maiden fable
#

Yea, user is None

astral musk
maiden fable
#

Can I see your code, for the 4th time?

cloud dawn
karmic totem
# maiden fable Can I see your code, for the 4th time?
  if message.channel.id == 891991473925541928:
    if message.content.startswith('-dmto '):
      try:
        us = message.content.split(' ')[1]
        user = client.get_user(int(us))
        await user.send(message.content.split[2])
      except Exception as e:
        await message.reply(e)```
maiden fable
#

Bruh

#

!d discord.ext.commands.Command

unkempt canyonBOT
#

class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.

These are not created manually, instead they are created via the decorator or functional interface.
maiden fable
#

Use this

#

Don't use on message for commands

astral musk
cloud dawn
karmic totem
maiden fable
#

Try printing us

karmic totem
#

ok

astral musk
#

Therefore there was no self passed to the method.

karmic totem
boreal ravine
#

If I have an error handler and I have a command error for a specific command how do I stop it from sending both of the errors if an error got raised?

astral musk
#

I could do something like

from cogs.cog_file_name import CogClassName


async def startup_code():
    CogClassName(bot).func.start()
    # Other stuff

but this seems weird and probably wrong. It feels weird because I am creating an instance of the class just for one function. Normally, when you import stuff, you can just use the function. However, since this function is part of a class, I need to use the class to call the function. And since the function needs self, it seems like I have to use an instance of the class instead of the class itself.

maiden fable
slate swan
unkempt canyonBOT
slate swan
#

remove () at your bot event decorator, it's not callable

astral musk
# slate swan make the function as a staticmethod if you're not using the instance in the func...

I think that I am using the instance in the function.
It's like this

class CogName(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @tasks.loop(count=1)
    async def looped_function__scheduler(self):
        # Do some stuff
        self.looped_function.start()
    
    @tasks.loop(hours=1)
    async def looped_function(self):
        # Do some stuff
        guild = discord.utils.get(self.bot.guilds, name=GUILD_NAME)

If I could get around referencing self in looped_function, I could also avoid using self in looped_function_scheduler. If I could do that, then I think that I could make looped_function_scheduler into a static method.
So now my question becomes: Is it possible to get the guild object in looped_function without using self.bot?

slate swan
#

And bot.process_commands() must be used at the end of the event

boreal ravine
karmic totem
slate swan
#

plz help me

slate swan
#

ctx.command.has_error_handler()

boreal ravine
#

hm

slate swan
boreal ravine
slate swan
slate swan
slate swan
slate swan
boreal ravine
astral musk
slate swan
slate swan
#

and tbh that's literally the point of an instance

astral musk
slate swan
astral musk
slate swan
#

yes

astral musk
#

I didn't think of that.

slate swan
#

that way you can stop them during unloading the cog so you dont duplicate the task

boreal ravine
slate swan
#

In your global error handler

astral musk
slate swan
#

When you make a global error handler you have ctx and the error as the params

#

So you can just do ctx.command to return the Command that raised the error

slate swan
weak kite
#

How should I go about saving all the messages from a channel in my private server (including messages in public/private threads) into a JSON file?

visual island
#

a database

#

json cant handle much traffic tho

astral musk
#

@slate swan I'm confused about how to start the looped_function in the looped_function_scheduler. Am I supposed to make both the scheduler and the looped function into staticmethods? When I try to start the looped_function in the looped_function_schedluler, it says that looped_function isn't defined.
Also, this doesn't solve the problem of using self in looped_function since I still need to get the guild. Perhaps though I could pass bot to the scheduler and then have the scheduler pass bot to the looped function. What do you think about this idea?

slate swan
surreal sierra
#

Hey is it possible to do this? I just want to change the color of the Embed and nothing else.

await slotbed.edit(color=discord.Color.green())
slate swan
surreal sierra
slate swan
left dove
#

make a clone of the same embed and just change the color

#

make a function for embeds

#

or some thing different

surreal sierra
astral musk
# slate swan what's wrong with just doing ```py class CogClass(commands.Cog): def __init_...

I could take your idea and start the scheduler like this

class CogClass(commands.Cog):
    def __init__(self, bot):
        self.my_task_scheduler.start()
    
    @tasks.loop(hours=1)
    async def my_task():
        ...
        # Need to reference bot in here

    @tasks.loop(count=1)
    async def my_task_scheduler(self):
        ...
        # Start my_task

The problem with this is that it appears as though my_task is not defined when I reference it in my_task_scheduler.

slate swan
surreal sierra
left dove
#

mate make a function for embeds which u want only the color to change

surreal sierra
#

Ah yea

astral musk
slate swan
left dove
#
async def my_embeds(color):
        embed=discord.Embed(title="hmm", description="",color=color)
        return embed
#....somewhere in code.....
my_em=await my_embeds(color=somecolor)
await ctx.send(embed=my_em)```
#

@surreal sierra

#

this might work

slate swan
#

why not just set the color attribute of the original embed like i originally suggested

left dove
#

hmm we can go to shop by front door and also through back door

astral musk
# visual island why staticmethod?

I thought that I was supposed to use staticmethod for the scheduler because the scheduler doesn't really need the instance of the class. The only reason I thought that it did need the instance of the class was because I didn't know how to reference looped_function without it.

slate swan
visual island
#

potatothink where did you define looped_function exactly?

astral musk
slate swan
astral musk
#

So I should be able to do this.

class CogClass(commands.Cog):
    def __init__(self, bot):
        self.my_task_scheduler.start()
    
    @tasks.loop(hours=1)
    async def my_task(self):
        ...

    @tasks.loop(count=1)
    async def my_task_scheduler(self):
        ...
        self.my_task.start()
ripe jackal
#

Hello, I'm trying to make command where I can create embed with commands. This is my code:

@client.command()
async def emek(ctx):
    def check(message):
        return message.author == ctx.author and message.channel == ctx.channel

    await ctx.send('Waiting for a title')
    title = await client.wait_for('message', check=check)
  
    await ctx.send('Waiting for a description')
    desc = await client.wait_for('message', check=check)
    
    await ctx.send('Channel ID')
    guild = client.get_guild(12345678)
    int((await client.wait_for('message', check=check)).content)
    channel_id = await client.wait_for('message', check=check)
    channel = guild.get_channel(int(channel_id.content))
    embed = discord.Embed(title=title.content, description=desc.content, color=discord.Color.blue())
    await channel.send(embed=embed)```
I do not get any error but when I send the channel id, nothing happens. What should I do?
left dove
slate swan
slate swan
astral musk
left dove
ripe jackal
#

please, read my code again and if you know what should i do, i will be really happy to see

left dove
#

can u explain clearly

#

i dont wanna see the code cuz its non-aligned as am in mobile

reef shell
#

You are not taking any arguments in the command

#

Like embed title, description

#

etc

#

Whatever you need to make your embed

ripe jackal
#

i want when i type .emek to send Waiting for a title, then i need to type a title for the embed, the bot checks it then sendsWaiting for a description, then checks again and sends Channel ID, where i need to answer with the channel id, where i want my embed to be sent

slate swan
#

they are using wait_for for that lol

reef shell
#

Oh mb

#

Didn’t notice

ripe jackal
reef shell
#

No no It's okay, i didn’t notice the wait_for part

ripe jackal
#

np, but what should i do

left dove
#

why do u need a channel id

#

?

ripe jackal
left dove
#

do u send the embed to some other channel?

ripe jackal
slate swan
#

probably a silenced error, do you have an error handler

ripe jackal
slate swan
#

anyone knows tag prefix?

ripe jackal
#

it's an old bot, prob before a year 1k lines bot lol

astral musk
#

@slate swanCan you think of a way get a looped task on a schedule in the task itself?

slate swan
left dove
# ripe jackal yes

btw u can also use

sendhere=client.get_channel(int(value))
await sendhere.send(embed=someembed)```
slate swan
astral musk
ripe jackal
left dove
slate swan
ripe jackal
slate swan
#

in your code here, ```py

int((await client.wait_for('message', check=check)).content)
channel_id = await client.wait_for('message', check=check)
#

you're doing wait_for twice, so perhaps when you sent the first channel id, it went to your int there, hence there isn't a reply or an error

#

probably you send it twice it will

ripe jackal
#

so i need to delete the int.... thing?

slate swan
#

yea, since you're not using it

ripe jackal
#

okay

astral musk
ripe jackal
#

will try

ripe jackal
# slate swan yea, since you're not using it

This is what i got after removing the line
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'get_channel'

#

where i place the id of the channel, the bot prints this

tough wagon
#

Hey! I want my embed to have fields like this:

Field 1 Field 2
Descr 1 Descr 2

Field 3 Field 4
Descr 3 Descr 4

But when I add inline=False to 3rd field, the 4th field goes to third line like this:

Field 1 Field 2
Descr 1 Descr 2

Field 3
Descr 3

Field 4
Descr 4

How can I fix that?

ripe jackal
reef shell
#

that's how inline =False work

slate swan
ripe jackal
#

the id is valid

tough wagon
ripe jackal
#

what should i do?

tough wagon
slate swan
left dove
reef shell
#

there should be a way of doing this , let me check

ripe jackal
#

@slate swan it worked, TYSM !!!!! ❤️ ❤️ ❤️

slate swan
slate swan
#

but this looks horrible in mobile

reef shell
#

oh,
yea embeds in mobile looks horrible anyways

left dove
#

yea

slate swan
elfin flicker
#

hello, Can someone help me, chat by private plis

little ether
shut axle
#
@client.command()
async def userinfo(ctx, member: discord.Member = None):
  member = ctx.author if not member else member
  roles = [role for role in member.roles]
  
  embed = discord.Embed(
    color = member.color, 
    timestamp = ctx.messages.created_at
  )
  embed.set_author(name=f"User Info - {member}")
  embed.set_thumbnail(url=member.avatar_url)
  embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.avatar_url)
  embed.add_field(name="ID:", value=member.id)
  embed.add_field(name="Guild Name:", value=member.display_name)
  embed.add_field(name="Created At:", value=member.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))
  embed.add_field(name="Joined At:", value=member.joined_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))
  embed.add_field(name=f"Roles ({len(roles)})", value=" ".join([role.mention for role in roles]))
  embed.add_field(name="Top Role:", value=member.top_role.mention)
  embed.add_field(name="Is Bot", value=member.bot)
  await ctx.send(embed=embed)

why it doesn't send the message?

heavy radish
#

How do I send a message to a certain channel? Like I do a command like ??ga <Whatever> I want to send the <Whatever> part to a particular channel

reef shell
#

take the channel id as an arg

#

then send there

shut axle
fallow mauve
#

how do i get my bot to wait, say, 5 seconds, before replying to the command?

shut axle
#

btw

fallow mauve
#

k

heavy radish
# reef shell take the channel id as an arg

Umm...

@bot.command()
async def ga(ctx, *, arg):
  if ctx.channel.id == 886837547328761868:
    await ctx.channel_send
    await ctx.send(arg)
``` What I've done is made the command channel specific. Now how do I make it send the `arg` to another channel. Do I create an arg like gachannel == 7875456789
reef shell
heavy radish
#

(I also want to send a copy to the channel the command was made. so thats why there is the last line)

shut axle
#

or making it like this:

@client.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        msg = '**Still on cooldown**, please try again in {:.2f}s'.format(
            error.retry_after)
        await ctx.send(msg, delete_after=6)

then use this in a command:

@commands.cooldown(1, 60, commands.BucketType.user)
#

u can change it any time.

reef shell
#

also which dpy version are you using

heavy radish
#

Me?

waxen granite
#

can we check a phrase in a role name?

#

like if "admin" in member.roles or something

reef shell
#

no sorry, lucus

heavy radish
#

Ohh

heavy radish
reef shell
fallow mauve
heavy radish
#

no no

#

I don't need them to choose

waxen granite
heavy radish
#

IDK sorry

fallow mauve
#

do i need to like enable it or smth?

reef shell
#

....

heavy radish
reef shell
#

i don't understand

#

what choose

heavy radish
#

like i want the output sent to a particular channel

fallow mauve
heavy radish
#

the particular channel doesnt change. I choose it once and thats where i want it to go

reef shell
heavy radish
#

Hm

#

ok

reef shell
#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
reef shell
#

make a custom check for this

#

!d discord.ext.commands.check

unkempt canyonBOT
#

@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").

These checks should be predicates that take in a single parameter taking a [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to the [`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") event.

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent 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").
heavy radish
#

Is this good?

reef shell
#

yeah, but it's better ga(ctx, *, arg : str)

heavy radish
#

ok

shut axle
#

@reef shell I have a querstion..

#
guild_ids = [i dont wanna pubish myserver ID]
@slash.slash(
  name="userinfo",
  description="Shows a user-info.",
  guild_ids = guild_ids
)
async def userinfo(ctx, member: discord.Member = None):
  member = ctx.author if not member else member
  roles = [role for role in member.roles]
  
  embed = discord.Embed(
    color = member.color, 
    timestamp = ctx.message.created_at
  )
  embed.set_author(name=f"User Info - {member}")
  embed.set_thumbnail(url=member.avatar_url)
  embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.avatar_url)
  embed.add_field(name="ID:", value=member.id, inline=False)
  embed.add_field(name="Guild Name:", value=member.display_name, inline=False)
  embed.add_field(name="Created At:", value=member.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"), inline=False)
  embed.add_field(name="Joined At:", value=member.joined_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"), inline=False)
  embed.add_field(name=f"Roles ({len(roles)})", value=" ".join([role.mention for role in roles]), inline=False)
  embed.add_field(name="Top Role:", value=member.top_role.mention, inline=False)
  embed.add_field(name="Is Bot", value=member.bot, inline=False)
  await ctx.send(embed=embed)

Why it is wrote: the interaction failed???

heavy radish
#

Quick question: How do I put the content of the arg in "between here" ??

hasty iron
#

wdym

heavy radish
#

Currently the output of this code will be whatever was after ??ga

#
@bot.command()
async def ga(ctx, *, arg : str):
  channel = bot.get_channel(886837532854198272)
  if ctx.channel.id == 886837547328761868:
    await channel.send(arg)
    await ctx.send (arg)
``` I want to place it between ""
hasty iron
#

you can do {arg!r} and make the string an fstring

hasty iron
#

!e ```py
arg = '123'
print(f'{arg!r}')

unkempt canyonBOT
#

@hasty iron :white_check_mark: Your eval job has completed with return code 0.

'123'
heavy radish
#

!e

arg = 1234
print(f"{arg!r}")
unkempt canyonBOT
#

@heavy radish :white_check_mark: Your eval job has completed with return code 0.

1234
heavy radish
#

F

#

I don't want to write it with ""

#

I want the bot to do it

hasty iron
#

you dont have to

#

i just told you how

heavy radish
#

!e

arg = 1234
print(f"'{arg!r}'")
unkempt canyonBOT
#

@heavy radish :white_check_mark: Your eval job has completed with return code 0.

'1234'
heavy radish
#

Hm

hasty iron
#

why?

#

arg in your case will always be a string

heavy radish
#

!e

arg = 1234
print('f"{arg!r}"')
unkempt canyonBOT
#

@heavy radish :white_check_mark: Your eval job has completed with return code 0.

f"{arg!r}"
hasty iron
#

???

heavy radish
#

I shall try

waxen granite
#
    @commands.command()
    async def listadmins(self, ctx):
        roleslist = ctx.guild.roles
        for role in roleslist:
            if "developer" in role.name:
                await ctx.send(role.name)```
its not working, what am i doing wrong?
compact field
#

guys how can i create log bot ?
on_bann
on_message_update
on_user_profile_update
like this

hasty iron
#

it must be that there isnt a role that contains "developer" in its name

waxen granite
#

if "developer".lower() in role.name: this is correct , right?

hasty iron
#

"developer" is already lower case though

waxen granite
#

yes ik

#

well i have a role Developer & Creater , doing "Developer".lower() in role.name: should get me that role name right?

little ether
hasty iron
#

no

#

Developer is not developer

waxen granite
fallow mauve
#

my friend is wanting me to add a credit/rpg system to the bot im making for our discord server, could someone walk me through that one-on-one by any chance? I'm not gonna be online for much longer but will be on this evening

heavy radish
#

ctx.author.name} whats the one to get their name and tag? but not mention

heavy radish
#

name and tag

#

【C E O】#8841

left dove
#

to get both name and tag just use ctx.author

heavy radish
#

ok

fallow mauve
fallow mauve
left dove
#

am asking tht to you?

#

wdym?

fallow mauve
#

i dont understand the question

#

"what is an rpg bot?"
"what do you mean /rpg?"
what do you mean

left dove
#

i also dont understand wdym by credits/rpg

fallow mauve
#

the way he put it he wants a "credit system" where you can use daily/work/etc. to gain bot currency

left dove
#

how can we help with that?

fallow mauve
#

i have no idea how to set that up, never done anything like it before

#

i have a friend who could help me but is not responding to my messages rn

#

hasnt for like a day now

waxen granite
#

how can i get members with a role having Admin in their roles name?

slate swan
#

guys, any idea on how i would make a flask app that can get a discord.py bots data in a seperate app? i guess some kind of discord api

red forge
slate swan
#

does that host my bot along with a flask application?

#

or like get the bots data from it

hasty iron
#

ipc is inter-process communication, it doesn’t host anything

slate swan
#

ah

#

ill look into it, thanks

fallow mauve
#

how do make it so that a command requires the user to have a certain permission to use?

slate swan
#

check if the author has that permission if they have it then do the command

fallow mauve
#

can u give me an example of how to put that in the code?

odd pendant
#

that's a decorator so you can put it where your command decorator is

fallow mauve
#

k

broken dirge
#

hello, can someone help me with this error

fossil sigil
#

send

#

can you send the error @broken dirge

waxen obsidian
#

Can anyone please help me?
I am trying to create a bot that needs to read the message and from the message take the email and send it the amount written through coinbase

broken dirge
#

raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: '<' not supported between instances of 'int' and 'str'

odd pendant
#

pass_context is deprecated

waxen obsidian
broken dirge
#

not sure I understand

odd pendant
# visual island typehint z to int

that won't change anything. the issue is await ctx.send("smaller" if (y < z) else "Bigger"), it should be await ctx.send("smaller" if (y < int(z)) else "Bigger")

visual island
odd pendant
#

ah yeah i guess, either use the typehint and remove all of the int conversions or convert them both manually

visual island
#

dpy converts the __annotations__ in your function to the type you expect

visual island
#

async def number(ctx, z: int):

#

this allows you to not do int() everytime

broken dirge
#

Thank you!

visual island
broken dirge
#

This was fast and useful! Great community.

waxen obsidian
#

I need this code

import json, hmac, hashlib, time, requests
from requests.auth import AuthBase

# Before implementation, set environmental variables with the names API_KEY and API_SECRET
API_KEY = 'API_KEY'
API_SECRET = 'API_SECRET'

# Create custom authentication for Coinbase API
class CoinbaseWalletAuth(AuthBase):
    def __init__(self, api_key, secret_key):
        self.api_key = api_key
        self.secret_key = secret_key

    def __call__(self, request):
        timestamp = str(int(time.time()))
        message = timestamp + request.method + request.path_url + (request.body or '')
        signature = hmac.new(self.secret_key, message, hashlib.sha256).hexdigest()

        request.headers.update({
            'CB-ACCESS-SIGN': signature,
            'CB-ACCESS-TIMESTAMP': timestamp,
            'CB-ACCESS-KEY': self.api_key,
        })
        return request

api_url = 'https://api.coinbase.com/v2/'
auth = CoinbaseWalletAuth(API_KEY, API_SECRET)

# Get current user
r = requests.get(api_url + 'user', auth=auth)
print r.json()
# {u'data': {u'username': None, u'resource': u'user', u'name': u'User'...

# Send funds
tx = {
    'type': 'send',
    'to': 'user@example.com',
    'amount': '10.0',
    'currency': 'USD',
}
r = requests.post(api_url + 'accounts/primary/transactions', json=tx, auth=auth)
print r.json()
# {u'data': {u'status': u'pending', u'amount': {u'currency': u'BTC'...

this is from coinbase developer web
How do I get
API_KEY and API_SECRET ?
@broken dirge

broken dirge
grim oar
#

import discord
import os
import music

my_secret = os.environ['TOKEN']

client = discord.Client()

cogs = [music]

client = commands.Bot(command_prefix='!', intents = discord.Intents.all())

for i in range(len(cogs)):
cogs[i].setup()

file "main.py", line 4, in <module>
import music

waxen obsidian
#

oh ok thx

broken dirge
#

I use Coinbase though

broken dirge
#

so it's interesting for me as well

waxen obsidian
ancient cipher
#

Hello guys I have a favor, is here someone who is master doing discord bots and something with blockchain etc...?

left dove
#

or ask the admin of that site to give u one

broken dirge
#

like

#

$number 5

#

if wrong

#

6

#

7

grim oar
#

import discord
import os
import music

my_secret = os.environ['TOKEN']

client = discord.Client()

cogs = [music]

client = commands.Bot(command_prefix='!', intents = discord.Intents.all())

for i in range(len(cogs)):
cogs[i].setup()

file "main.py", line 4, in <module>
import music

any1 know the problem?

visual island
unkempt canyonBOT
#

wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
left dove
slate swan
#

i think hes trying to import the cog

ancient cipher
#

hello? can anyone help me with openSea discord bot?

slate swan
#

i can help

#

if what you need is bad internet

fallow mauve
#

!d help

slate swan
#

lmao

ancient cipher
#

wdym about that? 😄

#

can we dm?

broken dirge
# visual island !d discord.ext.commands.Bot.wait_for

Which part of the code would I need to change? @ client.command(pass_context=True) async def number(ctx, z: int): y = randrange(100) await ctx.send('Guess the number!') while True: if y == z: await ctx.send("Congrats!") break await ctx.send("smaller" if (y < z) else "Bigger") return

slate swan
#

if what you need is bad internet i can help

broken dirge
slate swan
#

that pass_context=True is triggering me

broken dirge
broken dirge
slate swan
#

cuz its deprecated

slate swan
#

remove it

visual island
#

put that in your code

broken dirge
broken dirge
slate swan
#

then fix your token

visual island
#

what's \u21

#

!charinfo \u21

unkempt canyonBOT
visual island
broken dirge
#

u sure it should look like this? I dont think so!?

waxen granite
#
        if option.lower() == "helpers":
            role = discord.utils.get(guild.roles, name = "Helper")
            helpers = ""
            for member in guild.members:
                if role in member.roles:                    
                    helpers += f"{member.name}\n"
                    await ctx.send(f"Helpers:\n{helpers}")```
why does it show like that ?
broken dirge
#

@ client.command(pass_context=True) async def number(ctx, z: int): y = randrange(100) await ctx.send('Guess the number!') while True: if y == z: await ctx.send("Congrats!") break await ctx.send("smaller" if (y < z) else "Bigger") !d discord.ext.commands.Bot.wait_for

slate swan
#

🤦‍♂️

broken dirge
#

I'm sorry

#

I'm new to python

slate swan
#

await client.wait_for(...)

ancient cipher
#

@slate swan I sent u msg in dm

broken dirge
ancient cipher
#

Does anyone have experience with this type of discord bot?

stark hearth
#

wrong chat lmao

ancient cipher
#

nnaah or?

shut axle
# red forge You have to put options for the slash commands
guild_ids = [I dont wanna send here my id]
@slash.slash(
  name="ping",
  description="Bot latency.",
  guild_ids = guild_ids
)
async def ping(ctx):
  await ctx.send(f"Bot Latency = `{round(client.latency * 1000)}ms`")
``` Here is dont have it
#

No options..

ancient cipher
#

i mean if anyone have experience with API and something like that i can do beginning of the code but i have no idea how to do live events in discord bot and even where to start

#

mostly yes, because i couldnt find anything like this especially on NFTs

#

if I can call it like this

#

it will write who bought NFT when and how much

#

if u understand 😄

slate swan
#

who here can i ask about python decisions (if, else) i have a few questions?

broken dirge
#

@ client.command(pass_context=True) async def number(ctx, z: int): y = randrange(100) print(" ", y) await ctx.send('Guess the number!') while True: if y == z: await ctx.send("Congrats!") break await ctx.send("smaller" if (y < z) else "Bigger") return

ancient cipher
#

okaay thanks

broken dirge
#

How do I edit this code in a way that it asks for input unil it is == to answer?

broken dirge
#

which line of the code should I change?

ionic wadi
#

@commands.is_owner

Does this mean serverowner or bot owner?

maiden fable
#

Bot

waxen granite
#

role = discord.utils.get(guild.roles, id="891624660012257320") it returns none , but the role is there and id is correct

waxen granite
#

role = discord.utils.get(guild.roles, name = "BankTime") for member in guild.members: if role in member.roles: await ctx.send(len(member))
TypeError: object of type 'Member' has no len() whats wrong?

maiden fable
#

what u tryna do?

waxen granite
#

trying to count members with the role

maiden fable
#

U can do role.members

#

!d discord.Role.members

unkempt canyonBOT
ionic wadi
#

!codeblock

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.

ionic wadi
#
    @commands.command()
    @commands.is_owner()
    async def degrade(self, ctx, user: discord.Member=None):
        await ctx.send("Wie will je degraden?")
        try:
            message = await bot.wait_for("message", check=lambda m: m.author == ctx.author and m.channel == ctx.channel, timeout=190.0)
        except asyncio.TimeoutError:
            await ctx.send("Helaas reageerde je niet binnen 190 seconde! En de prompt is beeindigd.")
        else:
            user=message.content
            userembed = discord.Embed(title="Helaas, ik heb verdrietig nieuws voor u.", desccription="Afkomstig van: Colza Management")
            userembed.add_field(name="Waarom bent u ontslagen?", value="Dit is een inactiviteits wave, en we hebben u voor nu gedegradeerd ivm een tekort aan activiteit.")
            userembed.add_field(name="Niet mee eens?", value="Dm @APotato#4553, waarom is dit geen goede reden?")
            await user.dm(embed=userembed)
            await ctx.send("Het bericht is verstuurd")```

After I send the user I dont get any more response
waxen granite
#
        if option.lower() == "helpers":
            role = discord.utils.get(guild.roles, name = "Helper")
            for member in guild.members:
                if role in member.roles:
                    await ctx.send(f"Helpers:\n{member.name}")``` 
why does it send like this?
maiden fable
#

Idk which tho

slate swan
waxen granite
#

how can i make it send all name at once?

jade jolt
#

.join()

sage otter
#

^^^

maiden fable
#

!join

unkempt canyonBOT
#

Joining Iterables

If you want to display a list (or some other iterable), you can write:

colors = ['red', 'green', 'blue', 'yellow']
output = ""
separator = ", "
for color in colors:
    output += color + separator
print(output)
# Prints 'red, green, blue, yellow, '

However, the separator is still added to the last element, and it is relatively slow.

A better solution is to use str.join.

colors = ['red', 'green', 'blue', 'yellow']
separator = ", "
print(separator.join(colors))
# Prints 'red, green, blue, yellow'

An important thing to note is that you can only str.join strings. For a list of ints,
you must convert each element to a string before joining.

integers = [1, 3, 6, 10, 15]
print(", ".join(str(e) for e in integers))
# Prints '1, 3, 6, 10, 15'
sage otter
#

Instead of doing all of that you can just get the role object and join the members.

#

"\n".join(discord.Role.members)

jade jolt
#

yup

maiden fable
#

Ah yea, that

visual yarrow
visual island
#

in dpy's official server, yes

#

full changelog, no as it's development is stopped

reef shell
visual island
visual yarrow
visual island
waxen granite
slate swan
#

How do I do this?

Secretword = hi
async def secretword(ctx):
await ctx.send(hello)
past ermine
#

How to make multiple prefixes?

slate swan
reef shell
#

show your code?

#

also you're doing indentations wrong

#

!indent

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

slate swan
reef shell
#

you need a on_message event and check if the message content is the secret word

#

the response to that

maiden fable
#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
slate swan
# reef shell show your code?
secretword = ('crazy')
discord.Guild.fetch_channels = ('channels')


@client.event
async def on_message(ctx):
  channels = await ctx.guild.fetch_channels()
  if (message.content.startswith(secretword)):
maiden fable
#

Nope

slate swan
maiden fable
#
if secret_word in message.content:
    . . . . 
#

Ezzz

reef shell
#

the parameter passed to on_message in message , so even if you are passing ctx it is an instance of discord.Message

maiden fable
#

Yea

slate swan
maiden fable
#

Instead u can get ctx by await bot.get_context(message)

maiden fable
past ermine
maiden fable
#

Pass in a list of prefixes

#

Ezz

reef shell
waxen granite
#
        if option.lower() == "admins":
            roleslist = guild.roles
            for role in roleslist:
                if "Admin" in role.name:```
i have this code , i am trying to get all the roles which has `Admin` in their name and then getting all the members in those roles, how do i proceed now?
slate swan
boreal osprey
#

help, i am the owner of the server tryna ban my alt

reef shell
boreal osprey
# reef shell code?
@bot.command()
@commands.has_permissions(ban_members=True)
async def ban(ctx, member : discord.Member, *, reason=None):
    emb=discord.Embed(title = "member kicked!", description = f'I have banned {member.name} from the server! Reason: {reason}, color 0xff0303')
    emb.add_field(name="responsible moderator", value=f'{ctx.author.mention}', inline = False)
    emb.set_thumbnail(url=f'{ctx.member.avatar_url}')
    emb2=discord.Embed(title=f"You have been banned from {ctx.guild.name}", color=0xff0303)
    emb2.add_field(name="Responsible Moderator:", value=f'{ctx.author.name}', inline=False)
    emb2.add_field(name="Reason:", value=f'{reason}', inline=False)
    await member.send(embed=emb2)
    await member.ban(reason=reason)
    await ctx.send(embed=emb)

@ban.error
async def ban_error(ctx: commands.Context,error: commands.CommandError):
 if isinstance(error, commands.MissingPermissions):
    message = "you are missing the `ban members` permission to run this command"
    await ctx.send(message)

 elif isinstance(error, commands.MissingRequiredArgument):
     message = "ping someone to ban them!"
     await ctx.send(message)

 elif(error, ArgumentParsingError):
     message = "You can't ban your self or anyone that is the same role as you or higher!"
     await ctx.send(message)
slate swan
reef shell
#

then i can't help without knowing the error

slate swan
#

I forgot how to make a command only be able to sent from Dm

slate swan
#

guys

#

how do i login into my bot and get the users/@me/guilds list via discord api?

boreal osprey
slate swan
#

i think its only requiring token, or some stuff like that

#

but im not really sure

boreal osprey
#

you need a 3rd party app and the bot token i think

slate swan
#

but a token will surely be enough

boreal osprey
#

i need help though

gloomy coral
#

can any1 gimme idea of games for discord bot

slate swan
#

Or officially? Should I rather say

#

umm it will always stay like that

#

forks are a different matter

#

Man rip

#

Of to JS lol

boreal osprey
#

it just won't get any updates

slate swan
#

Yea but no slash commands

#

Also buttons I think

boreal osprey
#

it has those i think

slate swan
#
    @commands.command(aliases= ['purge','delete'])
    @commands.has_permissions(manage_messages=True)
    async def clear(self, ctx, amount):
        await ctx.channel.purge(limit=amount)
        embed=discord.Embed()
        embed.description = (f"Cleared {amount} messages.")
        await ctx.send(embed=embed)```
#

it gives me an error TypeError: '>' not supported between instances of 'str' and 'int'

#

Man this brings back memories :)

slate swan
boreal osprey
slate swan
#

alright one sec

#

Yea I still don't like python, but Ye amount : int or str but I think it's int

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

slate swan
#

"via discord api"

reef shell
#

You want the guilds list?

slate swan
#

yes

slate swan
#

this is a seperate flask app tho

slate swan
#

that's really strong ToS breaking lol

#

so it doesnt have anything to do with bot.guilds

#

self-bot?

reef shell
unkempt canyonBOT
boreal osprey
#

@reef shell can you help me now?

slate swan
#

this is a seperate flask app

#

I haven't used python in so long, but I think it's something to do with list

#

so it cant access the vars

#

man im just trying to make my bots website

slate swan
#

why do people assume my bots a self bot

#

Ye

reef shell
#

Yes

slate swan
#

any alternatives?

#

You can fork it tho if you have any changes

slate swan
reef shell
#

But they are not reliable yet

slate swan
#

hm

#

Rust is basically the Gentoo of all programming languages

jade jolt
#

im working on a custom one myself (with a team)

#

not a fork

slate swan
jade jolt
#

tbh

#

if you want a site for your bot, you should probably use JS instead

#

for the bot ^

slate swan
#

.env is dotenv to install right?

#

emerge dotenv

slate swan
#

and get the guilds count

jade jolt
#

but why

slate swan
#

thats all im trying to do

jade jolt
#

JS lets you do this easily.

slate swan
#

I dont think you can do this with python

#

Js is easy lol

#

it isnt possible in py?

jade jolt
#

not really

slate swan
#

len(bot.guilds)?

#

wdym by that?

#

Might be Idk, python is bad

slate swan
slate swan
#

you should be python is gud

jade jolt
#

its not the best ive used

slate swan
#

Rust is better and faster

#

anyone here an expert in python?

slate swan
jade jolt
slate swan
slate swan
#

But stepped away from the discord module

jade jolt
#

lua doesnt require indents, thats why i like it more

hasty iron
slate swan
#

Lua feels childish lol

jade jolt
#

how so

slate swan
#

Idk just feels like made for kids or seen on TV type

jade jolt
#

bruh

slate swan
jade jolt
#

you can use them if u want

#

different styles exist

#

the syntax in Lua is "harder" I'd say

slate swan
#

is pycord reliable?

jade jolt
#

its not good

slate swan
#

how about nextcord?

jade jolt
#

not heard of it

#

@hasty iron knows more about them

gilded kite
jade jolt
#

its in quotes so its not much harder but its there

hasty iron
jade jolt
#

thank you

slate swan
hasty iron
#

you’re better off using discord.py until discord puts out a breaking change

jade jolt
#

yupp

past ermine
#

how to make prefix if u ping bot

grim oar
#

from discord.ext.commands import Bot
from discord.ext.music import MusicClient, WAVAudio, Track

bot = Bot()

@client.command()
async def play(ctx):
voice_user = ctx.message.author.voice
music_client = await voice_user.channel.connect(cls=MusicClient)
track = Track(
WAVAudio('audio.wav'), # AudioSource
'This is audio' # name
)
await music_client.play(track)

bot.run('token') any problems?

past ermine
#

yes

jade jolt
#

a few

past ermine
#

you need to give bot a prefix

grim oar
#

yeah my friend sent me this he wanted me to check it

past ermine
#

and exchange @client.command() with @native granite

gilded kite
jade jolt
#

thats why its cooler

#

also it does have a package manager

gilded kite
#

You have to install 3rd package manager like Luarocks

jade jolt
#

my one came preinstalled with it

past ermine
#

i have an on_message event, is there a way to get a ctx and a message?
cuz i want to do

if ctx.guild.id
``` but i only have message 
i need to get the guild id
gilded kite
#

Luvit is also cool, Lua in NodeJS style

jade jolt
past ermine
#

ok

jade jolt
#

and await bot.get_context(message) iirc

past ermine
#

where does that belong?

past ermine
jade jolt
#

in on_message? you said you wanted ctx

#

just assign that to ctx

past ermine
#

ok

jade jolt
#

i said that

elfin flicker
#

i finished my bot
: D, who wants to try it

jade jolt
#

lol

past ermine
#

oop?

jade jolt
#

yes

past ermine
#

what is that

jade jolt
#

bruh

forest blade
#

Object oriented programming

past ermine
#

thanks

lament mesa
#

and you can use bot.get_context to get the Context object

half briar
#
@bot.command()async def tt(ctx): a = ctx.message.author.voice.channel await a.connect()
``` why bot not connect user voice channel
boreal ravine
half briar
#

Anyone can help?

past ermine
# boreal ravine wym

like that people can ping the bot and then help
like
@past ermine help
so that it displays message

river kindle
#

I would need a hand,

i am trying to do some bottno, but importing the libraries it tells me that the module does not exist, even if it has been installed, how do i fix it?

I imported this from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType

ripe jackal
#

Hello, I have command problem. I want to create invite-logger and when I invite someone - it doesn't show. The same with kicking/leaving. What should I do? This is the command now ```python
@client.event
async def on_invite_create(invite,self):
await self.tracker.update_invite_cache(invite)

@client.event
async def on_guild_join(guild,self):
await self.tracker.update_guild_cache(guild)

@client.event
async def on_invite_delete(invite,self):
await self.tracker.remove_invite_cache(invite)

@client.event
async def on_guild_remove(guild,self):
await self.tracker.remove_guild_cache(guild)

@client.event
async def on_member_join(member,self):
inviter=await self.tracker.fetch_inviter(member)
data = await self.client.invites.find(inviter.id)
if data is None:
data={"_id": inviter.id, "count":0,"userInvited":[]}

    data["count"]+=1
    data["usersInvited"].append(member.id)
    await self.client.invites.upsert(data)

    channel=discord.utils.get(member.guild.text_channels, name="invites")
    embed= discord.Embed(title=f"Welcome {member.display_name}", description=f"Invited by: {inviter.mention}\nInvites: {data['count']}", timestamp=member.joined_at)
    embed.set_thumbnail(url=member.avatar_url)
    embed.set_footer(text=member.guild.name, icon_url=member.guild.icon_url)
    await channel.send(embed=embed)```
#

and how do I repair this?

boreal ravine
past ermine
#

yes

boreal ravine
#

hm

#

!d discord.ext.commands.when_mentioned

unkempt canyonBOT
#

discord.ext.commands.when_mentioned(bot, msg)```
A callable that implements a command prefix equivalent to being mentioned.

These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.
thin cedar
#
if message.content.startswith('cfur info'):
      await message.channel.send(embed = discord.Embed(title="Crystal Fur Bot", description='Crystal Fur Bot\nRevision 9\nOwner: Crystal Fur#5411'))

why will the error say it has no perms when it has

boreal ravine
#

can the bot talk in the channel?

thin cedar
#

yes

boreal ravine
ripe jackal
boreal ravine
#

hm

thin cedar
#
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 15, in on_message
    await message.channel.send(embed = discord.Embed(title="Crystal Fur Bot", description='Crystal Fur Bot\nRevision 9\nOwner: Crystal Fur#5411'))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 1065, in send
    data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 248, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
sage otter
#

The bot is missing permissions.

thin cedar
#

it has permissions

#

all the nessary ones

sage otter
#

Read the error for yourself then and decide.

past ermine
boreal ravine
past ermine
#

just this?

#

discord.ext.commands.when_mentioned

thin cedar
#

yes

boreal ravine
sage otter
#

NoneType has no method send or something

boreal ravine
#

hm

ripe jackal
sage otter
#

It’s erroring out on send

jade jolt
#

does the bot have send_messages permission?

sage otter
#

So it’s obviously a permission error with the bot not being able to send the message

past ermine
#
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 155, in help
    async def on_member_join(member):
  File "/home/runner/GelbieLvl/help.py", line 24, in helpcmd
    await ctx.send(embed=embhelp)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/dpy_overrides.py", line 323, in send_override
    return await send(channel, *args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/dpy_overrides.py", line 300, in send
    data = await state.http.send_message(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 248, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
thin cedar
#

could the attach files be a problem

past ermine
#

and many more

boreal ravine
#

@past ermine give it admin

past ermine
#

(the bot has admin)

boreal ravine
#

hm

sage otter
past ermine
boreal ravine
#

what

past ermine
#

all perms

jade jolt
#

Those are the permissions

boreal ravine
#

hm

thin cedar
sage otter
#

@thin cedar give your bots any permission associated with messages

thin cedar
#

it has all

sage otter
#

Just send messages, embed links, attach files, etc

jade jolt
#

yup

sage otter
#

If it still doesn’t work after giving it everything you fucked your permissions some how.

jade jolt
#

^^^

boreal ravine
#

or reinvite the bot might be a solution

past ermine
#

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 197, in on_message
await client.process_commands(message)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 975, in process_commands
ctx = await self.get_context(message)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 909, in get_context
raise TypeError("Iterable command_prefix or list returned from get_prefix must "
TypeError: Iterable command_prefix or list returned from get_prefix must contain only strings, not function

past ermine
#

what do you want to see exactly?

#

it is 600 lines

left dove
#

hmm ok then debug ur self

#

thats the only way

#

wait what

#

see the typeError

#

what u passed a function to the prefix?

#

custom prefix func?

past ermine
#

client = commands.Bot(command_prefix=['gl<',"!",discord.ext.commands.when_mentioned], intents=intents, help_command=None,case_insensitive=True)

#

this is the prefixes

left dove
#

line number?

past ermine
#

25

left dove
#

whats in 197 line?

past ermine
#

await client.process_commands(message)

left dove
#

mate my idea is

past ermine
#

bc it is in an on_message

past ermine
#

yeah, but i wanted to make it a prefix, when the bot is mentioned

left dove
#

u can make it via another method

past ermine
#

and i tried <@botid> and Botname#discriminator

left dove
past ermine
#

yes

left dove
#

tell if the problem comes even after removing?

past ermine
#

no

left dove
#

that typerror gone?!

past ermine
#

yes

left dove
#

then u may create a on_message function

past ermine
#

yes, i already did

left dove
#

instead

#

<@!botid>

#

try this

left dove
#

@past ermine ping me if it works

past ermine
left dove
#

mate u must also make another client like

jade jolt
#

what are you trying

left dove
jade jolt
#

uhh

#

i know a way brb

left dove
#

ok tell

jade jolt
#
def get_prefix(bot, message):
    prefixes = ["%", "$"]

    if not message.guild:
        return '$'

    return commands.when_mentioned_or(*prefixes)(bot, message)
#

and commands.Bot(command_prefix=get_prefix)

left dove
slate swan
#

?

left dove
#

i use async for my custom prefix function

jade jolt
#

nothing in there uses await..?

left dove
#

no

slate swan
#

hes not awaiting on anything is he? hes just grabbing values that are already there

jade jolt
#

yup

left dove
#

no need of await

slate swan
#

yea then no async def

jade jolt
#

ty

past ermine
#

ok

half briar
#

Hey

#
@bot.command()async def tt(ctx): a = ctx.message.author.voice.channel await a.connect()
``` bot not join voice channel
sage otter
#

why is everything on the same line lmao or is that just me being on mobile

ancient cipher
#

Hi 😄 i have a problem with adding roles to someone if he reacts on msg, there is a problem in line 29 can someone quickly look what is wrong?

half briar
#

@sage otter

#

Yes

hasty iron
sage otter
half briar
#

Error is ``` PyNaci library needed to use

sage otter
#

Install PyNacl then

#

That lib is needed for voice support

half briar
#

But how to voice use

jade jolt
#

did you do pip install discord.py[voice]?

half briar
#

Yes but still error

ancient cipher
#

thanks tylerr ill try

sage otter
#

Why you thanking me lol. Blanket is the one who helped you.

ancient cipher
#

oh sorry

#

i mean blanket

#

xD

half briar
#

@sage otter ?

#

How to slove

sage otter
half briar
#

I tried

ancient cipher
#

anyway still its not working xDD

half briar
#

But not working

sage otter
half briar
#

i install discord[voice] and pynaci

#

But not work

sage otter
#

What doesnt work? The bot joining the channel or the installation?

hasty iron
unkempt canyonBOT
hasty iron
#

thats what i mean

ancient cipher
#

oh okaaaaaaaaaaaaaay

half briar
#

@sage otter you can give full code my not work

hollow mortar
#

hello

#

i want ask a question i cant have 2 on_raw_reaction on a discord bot event ?

unkempt canyonBOT
#

Hey @hollow mortar!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

hollow mortar
#

like here

#

the first on_RAW_reaction doesnt work

#

idk why

sage otter
#

No.
You were already told what to do. After installing PyNacI you should of been fine. If the bot isn’t able to join the voice channel still after installing I’d try restarting. If still nothing you did something wrong.

hasty iron
half briar
#

@sage otter

hasty iron
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)").

Example...
half briar
#

Ok i try

hollow mortar
ionic wadi
#

File "/home/container/bot.py", line 110, in on_member_join
await channel2.edit(name=f"Leden: [{bot.guild.member_count}]")
AttributeError: 'Bot' object has no attribute 'guild'

hollow mortar
#

any help

ionic wadi
#

@bot.listen()
async def on_message(message):
(some code)

jade jolt
#

@bot.listen()*

ionic wadi
#

If using bot.event you will need to use process. And this will automatically process It because It only listens and doesnt save everything.

hollow mortar
#

so i should change them both to @bot.listen ?

ionic wadi
#

Yeah,

hollow mortar
#

i changed one of them and still same problem one of them work and the other wont work

#

oh ok im trying now

ionic wadi
#

Try putting It all In one event.

jade jolt
#

you could do @bot.listen("on_message") if you need that

hollow mortar
#
@bot.listen()
async def on_raw_reaction_add(payload):
    if payload.member.id != bot.user.id and str(payload.emoji) == u"📥":
        msg_id, channel_id, category_id = bot.ticket_configs[payload.guild_id]

        if payload.message_id == msg_id:
            guild = bot.get_guild(payload.guild_id)
            role = guild.get_role(891031599708266629) #replace role_id with your role's id
            for category in guild.categories:
                if category.id == category_id:
                    break

            channel = guild.get_channel(channel_id)

            ticket_channel = await category.create_text_channel(f"ticket-{payload.member.display_name}", topic=f"A ticket for {payload.member.display_name}.", permission_synced=True)
            
            await ticket_channel.set_permissions(payload.member, read_messages=True, read_message_history=True, send_messages=True)
            await ticket_channel.set_permissions(role, read_messages=False, send_messages=False)

            message = await channel.fetch_message(msg_id)
            await message.remove_reaction(payload.emoji, payload.member)

            await ticket_channel.send(f"{payload.member.mention} Thank you for creating a ticket! Use **'-close'** to close your ticket.")

            try:
                await bot.wait_for("message", check=lambda m: m.channel == ticket_channel and m.author == payload.member and m.content == "-close", timeout=3600)

            except asyncio.TimeoutError:
                await ticket_channel.delete()

            else:
                await ticket_channel.delete()```
#

this is the first event

#
bot.listen()
async def on_raw_reaction_add(payload):
    message_id = payload.message_id
    if message_id ==  891791302004465665: ## add id msg of the msg you want ppl to react to to get role 
        guild_id = payload.guild_id
        guild = discord.utils.find(lambda g: g.id ==guild_id, bot.guilds)
        if payload.emoji.name == 'AU':
            role = discord.utils.get(guild.roles, name='AU')
        elif payload.emoji.name == 'NA':
            role = discord.utils.get(guild.roles, name='NA')
        else:
            role = discord.utils.get(guild.roles, name=payload.emoji.name)
        if role is not None:
            member = payload.member
            if member is not None:
                await member.add_roles(role)
                print("done")
            else: 
                print("memeber not found")
        else:
            print("role not found ")```
jade jolt
#

thats why

hollow mortar
#

this is the second and didnt work

#

why ?

jade jolt
#

@bot.listen()

#

you forgot the @ in the second one

hollow mortar
#

i have the @

jade jolt
#

no

hollow mortar
#

and still wont work

#

i changed it and didnt work

jade jolt
#

code shows it doesnt

digital pasture
#

hi

jade jolt
#

hello

hollow mortar
#

nvm

#

you are right it got removed

#

it works now thanks guys thanks alot

jade jolt
#

np

slate swan
#

yo
i have this line of code

    @commands.Cog.listener()
    async def on_message(self, message):
        for guild in self.client.guilds:
            if message.author.guild_permissions.administrator:
                pass
            if message.author.guild.default_role.permissions:
                if "test" in message.content.lower():
                    logschannel = self.client.get_channel(892095338075271189)
                    author = message.author
                    await message.delete()
                    await message.channel.send(F"{author.mention} Δεν έχεις perms για να στέλνεις test")
                    await self.client.process_commands(message)
                    em = discord.Embed(title="Κάποιος έκανε ένα test!",description='', color=orange)
                    em.add_field(name = f'{author.name} έστειλε', value= f"{message.content}", inline = True)
                    await logschannel.send(embed=em)

and i want it when someone has admin, it doesnt delete the message, and if he doent have then it deletes it

steep estuary
left dove
steep estuary
#

like this emoji "lemon_blush " is in this server if i want my bot to use it in any server than?

#

@left dove

jade jolt
#

it would need to share a server with that emoji

left dove
steep estuary
#

:okay:

left dove
#

this is its id 75...84

#

btw yea it need share access

steep estuary
#

i tried my server emoji

steep estuary
left dove
unkempt canyonBOT
#

Star / Wildcard imports

Wildcard imports are import statements in the form from <module_name> import *. What imports like these do is that they import everything [1] from the module into the current module's namespace [2]. This allows you to use names defined in the imported module without prefixing the module's name.

Example:

>>> from math import *
>>> sin(pi / 2)
1.0

This is discouraged, for various reasons:

Example:

>>> from custom_sin import sin
>>> from math import *
>>> sin(pi / 2)  # uses sin from math rather than your custom sin

• Potential namespace collision. Names defined from a previous import might get shadowed by a wildcard import.
• Causes ambiguity. From the example, it is unclear which sin function is actually being used. From the Zen of Python [3]: Explicit is better than implicit.
• Makes import order significant, which they shouldn't. Certain IDE's sort import functionality may end up breaking code due to namespace collision.

How should you import?

• Import the module under the module's namespace (Only import the name of the module, and names defined in the module can be used by prefixing the module's name)

>>> import math
>>> math.sin(math.pi / 2)

• Explicitly import certain names from the module

>>> from math import sin, pi
>>> sin(pi / 2)

Conclusion: Namespaces are one honking great idea -- let's do more of those! [3]

[1] If the module defines the variable __all__, the names defined in __all__ will get imported by the wildcard import, otherwise all the names in the module get imported (except for names with a leading underscore)
[2] Namespaces and scopes
[3] Zen of Python

steep estuary
#

like mee6 have custom emojis

left dove
left dove
#

then create emojis and upload

steep estuary
#

??

#

where?

left dove
#

to ur server

steep estuary
#

my bot is in many servers i cannot tell them all to put that emoji :/

jade jolt
#

no?

#

just put it in one

#

then itll work globally

steep estuary
#

okay like i have a emoji

#

that how i can use it ?

left dove
#

ow mean i just misconfused by his words

left dove
slate swan
#

Hello i'm new in conding and i dont khnow how to code this

in a embed it send a reaction when a member click it it sends a message in dms

steep estuary
#

i just mean like this server have this emoji lemon_unamused how any bot can use a servers emoji in every server

left dove
#

mate its like u need your bot to be in that server where u need to fetch the emoji from

steep estuary
#

i just want my bot a emoji that is not in the server

left dove
#

btw if u cant add your bot to that server then download that emoji and upload it to your private server where bot is in..

steep estuary
#

but mee6 also send

left dove
#

its in many server

#

so it can fetch from somewhere

steep estuary
#

my bot cannot fetch emojis?

valid niche
steep estuary
#

like this mee6 used a emoji that is not in that server

left dove
ripe jackal
#

Hello, I have an error. I want to make invite logger, but there is a problem. When I invite someone - it doesn't show. The same with kicking/leaving. What should I do(pls help)? This is the command now:

@client.event
async def on_invite_create(invite,self):
    await self.tracker.update_invite_cache(invite)

@client.event
async def on_guild_join(guild,self):
    await self.tracker.update_guild_cache(guild)

@client.event
async def on_invite_delete(invite,self):
    await self.tracker.remove_invite_cache(invite)

@client.event
async def on_guild_remove(guild,self):
    await self.tracker.remove_guild_cache(guild)

@client.event
async def on_member_join(member,self):
    inviter=await self.tracker.fetch_inviter(member) # inviter is the membed who invited
    data = await self.client.invites.find(inviter.id)
    if data is None:
        data={"_id": inviter.id, "count":0,"userInvited":[]}

        data["count"]+=1
        data["usersInvited"].append(member.id)
        await self.client.invites.upsert(data)

        channel=discord.utils.get(member.guild.text_channels, name="invites")
        embed= discord.Embed(title=f"Welcome {member.display_name}", description=f"Invited by: {inviter.mention}\nInvites: {data['count']}", timestamp=member.joined_at)
        embed.set_thumbnail(url=member.avatar_url)
        embed.set_footer(text=member.guild.name, icon_url=member.guild.icon_url)
        await channel.send(embed=embed)```
#

and how do i repair this?

left dove
#

from discord import <!!>

high flame
#

!d discord.Client.create_guild

#

i never thought this exists

jade jolt
#

but why is it needed

left dove
#

wtf

#

mate what

#

wait that means...

#

we can create guilds through bots

jade jolt
#

if its under 10 guilds itself

left dove
#

is that not against tos?

jade jolt
#

cant be abused much anyway

left dove
high flame
#

read last line lmao

left dove
steep estuary
#

what this do?

high flame
#

read it's name bruh

left dove
#

creates server

steep estuary
#

aaaaaa

left dove
#

like what we do

steep estuary
#

bot create a guild?

left dove
#

yea

#

but today only i itself came to know lol

steep estuary
#

lol

#

i also heard that first time that bots can create server too

#

than who will be the owner?

#

and that bot also join that server?

left dove
high flame
steep estuary
#

only bot in server?

left dove
#

:kekw:

steep estuary
#

than who makes role and how :/

jade jolt
#

the bot?

steep estuary
#

i think ctx.author :/

left dove
steep estuary
#

but by themself?

left dove
#

yea

#

if they have required perms

steep estuary
high flame
steep estuary
#

but a owner handle the server by his own

left dove
#

still in woder that

#

wtf this feature

#

exists

#

lol

jade jolt
#

discordia has it too

left dove
jade jolt
#

discord api for lua

left dove
#

oww

#

lua? kinda a programming lang?

high flame
#

yeah

#

a bit similar to python

left dove
#

hmm

jade jolt
left dove
#

ok gtg bye had nice conversation

jade jolt
#

okay cya 👋

left dove
#

👍

#

😴

jade jolt
#
select(2, check(message, 'respond'))
``` this is nice
#

thats how you get a certain value from a multiple return statement in lua ofc

hoary gust
#
@app.route("/dashboard")
async def dashboard():
    if not await discord.authorized:
        return redirect(url_for("login")) 

even if i am authorized i am still getting redirected to login but why and i am using heroku is that the reason?

#

@patent lark

maiden fable
#

Calm down, don't ping randoms

hoary gust
#

sry but his name is something like that

#

@maiden fable do u know any python lib for ipc

#

except discord-etx-ipc

odd pendant
#

multiprocessing.connection

ripe jackal
#

Hello, I have an error. I want to make invite logger, but there is a problem. When I invite someone - it doesn't show. The same with kicking/leaving. What should I do(pls help)? This is the command now:

@client.event
async def on_invite_create(invite,self):
    await self.tracker.update_invite_cache(invite)

@client.event
async def on_guild_join(guild,self):
    await self.tracker.update_guild_cache(guild)

@client.event
async def on_invite_delete(invite,self):
    await self.tracker.remove_invite_cache(invite)

@client.event
async def on_guild_remove(guild,self):
    await self.tracker.remove_guild_cache(guild)

@client.event
async def on_member_join(member,self):
    inviter=await self.tracker.fetch_inviter(member) # inviter is the membed who invited
    data = await self.client.invites.find(inviter.id)
    if data is None:
        data={"_id": inviter.id, "count":0,"userInvited":[]}

        data["count"]+=1
        data["usersInvited"].append(member.id)
        await self.client.invites.upsert(data)

        channel=discord.utils.get(member.guild.text_channels, name="invites")
        embed= discord.Embed(title=f"Welcome {member.display_name}", description=f"Invited by: {inviter.mention}\nInvites: {data['count']}", timestamp=member.joined_at)
        embed.set_thumbnail(url=member.avatar_url)
        embed.set_footer(text=member.guild.name, icon_url=member.guild.icon_url)
        await channel.send(embed=embed)```
#

pls help

#

🙏

hoary gust
odd pendant
#

this is what i used, i was messing around with ipc earlier and it's really simple

hoary gust
odd pendant
hoary gust
odd pendant
#

can you elaborate because thats what ipc is

jade jolt
#

i saw that

hoary gust
odd pendant
#

yes