#discord-bots

1 messages · Page 658 of 1

slate swan
#

yes use them

#

Dont use on_message for commands

#

use the Bot framework instead of client

vast gale
#

!code @whole tapir

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.

wild comet
#

"discord.ext.commands.errors.MissingRequiredArgument: question is a required argument that is missing."?

slate swan
#

you used the command without providing an argument

slate swan
wild comet
#

What do you mean, im sorry Im like brand new to python lol

slate swan
slate swan
wild comet
#

Could I send my code so you have more reference?

slate swan
#

can discord bots check the result of a discord search?

wild comet
#

Ima warn you now lol my discord is more of a meme bot lol

slate swan
#

like how much results were found

wild comet
wild comet
#

oof

slate swan
#

🚶

wild comet
#

oof

slate swan
slate swan
wild comet
#

OH IM SO DUMB

#

lol ty

slate swan
full valley
#

How can I make a footer timestamp in an embed that displays the time for the user.

#

I cant wrap my head around datetime, tried reading the docs and all

slate swan
#

timestamp=datetime.datetime.now()

#

Youll have to import datetime

full valley
#

so its not fully accurate

slate swan
worldly bane
full valley
worldly bane
#

if you import it using


worldly bane
full valley
#

im looking for a timestamp in the embed that displays the user the time depending on their timezone

novel apexBOT
#

This is not a Modmail thread.

full valley
#

Well In the discord.py discord, ive been told it is

full valley
worldly bane
#

IN THE EMBED DESCRIPTION

#

or title

full valley
#

Oh so you cant put it in the footer

worldly bane
#

tried

#

sorry for caps lol

full valley
#

damn thats kind of dumb

prisma spoke
#
Ignoring exception in on_command_error
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 168, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\admin\Downloads\underdev.py", line 233, in brackets
    data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a))
  File "C:\Python310\lib\site-packages\aiosqlite\core.py", line 184, in execute
    cursor = await self._execute(self._conn.execute, sql, parameters)
  File "C:\Python310\lib\site-packages\aiosqlite\core.py", line 129, in _execute
    return await future
  File "C:\Python310\lib\site-packages\aiosqlite\core.py", line 102, in run
    result = function()
ValueError: parameters are of unsupported type

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\nextcord\client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\admin\Downloads\underdev.py", line 125, in on_command_error
    raise error
  File "C:\Python310\lib\site-packages\nextcord\ext\commands\bot.py", line 995, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 895, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 177, in wrapped
    raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: parameters are of unsupported type```
#
@bot.command()
async def brackets(ctx,p:int):
    a = int(p*2)
    data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a))    
    dataa  = await data.fetchall()
    print(dataa)
    print(data)
    dt = list(dataa)
    print(dt)
    for i in range(1,len(dt),2):
        await ctx.send(dt[i],dt[i+1])```
slate swan
full valley
#

so that doesnt rly help me

obsidian ledge
slate swan
obsidian ledge
slate swan
#

yea swag is correct , using the timestamp kwarg is better than mentioning time in footer since it won't change

prisma spoke
#

u have to do embed.timestamp = datetime.datetime.utcnow()

slate swan
#

That's same

prisma spoke
slate swan
#

Why add it as a footer when you have a kwarg for it

full valley
#

but where does the timestamp show if u put it as a kwarg

slate swan
#

I dont see why

slate swan
prisma spoke
full valley
#

thankyou so much, i was overcomplicating it real bad

slate swan
full valley
#

is there a way to change the timestamp format?

obsidian ledge
#

donno

slate swan
#

not the embed timestamps

full valley
#

so it will always be •Today at 12:43 PM

slate swan
#

it gets updated automatically

full valley
#

Nah I mean the overall format

#

like I cant change it to | 12:43 PM

slate swan
#

Nope you can't

#

Here's how it changes

full valley
#

How do you change it to that

slate swan
#

Discord does that automatically

prisma spoke
slate swan
#

@full valley as said by sarthak

prisma spoke
#

never saw tht

full valley
#

its a little messy now

slate swan
#

Don't ask me where

prisma spoke
#

i didnt know discord does that too

slate swan
prisma spoke
#

well how do i do tht..

#

is it possible to do that?

slate swan
slate swan
#

thats done by discord and your device

#

unrelated to your code

#

Yeah

prisma spoke
#

ic

full valley
#

damn

#

would be kind of nice if we could change that formatting

slate swan
#

sadly its a discord limitation xd

#

i was wondering if this is for server name or id

#

its for a guild object

#

Takes any as its a guild object

#

ahh

maiden fable
#

😐

slate swan
maiden fable
#

I was never here

slate swan
maiden fable
slate swan
#

its py await <guildobject>.leave()

prisma spoke
slate swan
maiden fable
slate swan
prisma spoke
maiden fable
#

I swear discord snowflake server fucking kills my mobile and PC

slate swan
#

mute it already

#

i wasn't able to get in

#

🙏

#

so im trying to make my help command look like this command_name/alias but its giving me this error, what do i do?

class HelpPageSource(menus.ListPageSource):
    def __init__(self, data, helpcommand):
        super().__init__(data, per_page=6)
        self.helpcommand = helpcommand

    def format_command_help(self, no, command):
        signature = '/'.join([str(command), command.aliases])
        docs = self.helpcommand.get_command_signature(command)
        return f"`{signature}`: {docs}"
    
    async def format_page(self, menu, entries):
        page = menu.current_page
        max_page = self.get_max_pages()
        starting_number = page * self.per_page + 1
        iterator = starmap(self.format_command_help, enumerate(entries, start=starting_number))
        page_content = "\n".join(iterator)
        embed = discord.Embed(
            title=f"Help Command", 
            description=page_content,
            color=0xffcccb,
            timestamp=datetime.utcnow()
        )
        embed.set_footer(text=f"{page + 1}/{max_page}")
        return embed```
maiden fable
slate swan
#

command.aliases is a list , and join works only with strings

static lintel
#

for some reason, this doesn't change the status of my bot (i cut out client.run("token") from the screenshot)

maiden fable
#

Lmfao

slate swan
unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

slate swan
# slate swan

my man , guildobject being a guild object like ctx.guild or message.guild smthing

maiden fable
#

Also why not just set the status once instead of changing again and again?

slate swan
maiden fable
slate swan
#

Dont you have to do a wait_until_ready? To change presence

maiden fable
#

If u r doing it in on_ready then yea

slate swan
slate swan
slate swan
#

nu

#
@bot.command()
@commands.check(checkk)
async def verify(ctx):
    await ctx.send('1996, 1981')

    def check(m):
        return m.author.id == ctx.author.id

    msg = await bot.wait_for('message', check=check)
    if msg.content == '1996':
        await ctx.send('Correct')
    else:
        await ctx.send("Correct")

    if time3.content == '1981':
        await ctx.send('Incorrect')
    else:
        await ctx.send('No')``` lets say i want multiple questions to be sent, and lets say i have them defined like '`question1 : answer1, question2 : answer2`, how can i randomly select a question, and make the bot `wait_for()` the proper response
#

the line i sent will give you a list of all aliases , which you can join using .join() for the command signature you would be using something else

prisma spoke
#
@bot.command()
async def brackets(ctx,p:int):
    a = int(p*2)
    data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a,))    
    dataa  = await data.fetchall()
    dt = list(dataa)
    await ctx.send(dt)```
```py
[(808940512979451934, 5, 'd'), (726046274624684034, 2, '2j'), (766217463184228353, 4, 'aa'), (854639229802774538, 2, 'h')]```
#

i want it to send only the ids

slate swan
#

docs = self.helpcommand.get_command_signature(command) doesnt this already give you the signature?

prisma spoke
#

and in a format like <@!idhere> vs <@!idhere>
<@!id2here> vs <@!anotheridhere>

#

how to do it..

slate swan
prisma spoke
static lintel
static lintel
slate swan
unkempt canyonBOT
#

Sorry, an unexpected error occurred. Please let us know!

ClientResponseError: 500, message='Internal Server Error', url=URL('http://snekbox.default.svc.cluster.local/eval')

slate swan
#

wtf

maiden fable
static lintel
#

yeah i had everything enabled from the portal

prisma spoke
#

lmfai

maiden fable
#

Oh

slate swan
#
@bot.command()
@commands.check(checkk)
async def verify(ctx):
    await ctx.send('1996, 1981')

    def check(m):
        return m.author.id == ctx.author.id

    time3 = await bot.wait_for('message', check=check)
    if time3.content == '1996':
        await ctx.send('Correct')
    else:
        await ctx.send("Correct")

    if time3.content == '1981':
        await ctx.send('Incorrect')
    else:
        await ctx.send('No')``` lets say i want multiple questions to be sent, and lets say i have them defined like '`question1 : answer1, question2 : answer2`, how can i randomly select a question, and make the bot `wait_for()` the proper response
slate swan
maiden fable
obsidian ledge
#

how do i make like a list of commands in one embed?
like if i were to say !help moderation then the bot would send all of the commands that helps with moderation?

prisma spoke
slate swan
slate swan
#

and use Cog.commands to get a list of mod commands

slate swan
#

whos glow

slate swan
prisma spoke
slate swan
#

im not using a video

prisma spoke
#

@commands.check(checkk)

slate swan
#

dude i just named a check checkk

#

im no skid lmao

prisma spoke
#

in the next line

#

and u r using that..

#

so what will be the use of @commands.check()

slate swan
#

its a sub define

#

its a check within the command

#

that check is for the wait_for

prisma spoke
#

sub define what :what:

maiden fable
#

@static lintel can u add a debug print at the top of the event to see if it's trigerring?

slate swan
#

wait what , the bot...

upbeat otter
#

!d discord.ext.commands.Bot.wait_for

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

i forgot the doc thing, but check is an attr of waitfor

prisma spoke
slate swan
#

see

prisma spoke
upbeat otter
slate swan
#

anyways, back to it

@bot.command()
@commands.check(checkk)
async def verify(ctx):
    await ctx.send('1, 2')

    def check(m):
        return m.author.id == ctx.author.id

    time3 = await bot.wait_for('message', check=check)
    if time3.content == '1':
        await ctx.send('Correct')
    else:
        await ctx.send("Correct")

    if time3.content == '2':
        await ctx.send('Incorrect')
    else:
        await ctx.send('No')``` lets say i want multiple questions to be sent, and lets say i have them defined like '`question1 : answer1, question2 : answer2`, how can i randomly select a question, and make the bot `wait_for()` the proper response
prisma spoke
#

sus

upbeat otter
slate swan
#

how would i make docs into the help description for a command?

@client.command(aliases=['rep', 'r'], help="Repeats given text for x amount of times", usage="<amount> <text>")
@commands.cooldown(1, 5, commands.BucketType.user)
async def repeat(ctx, amount: int, content="repeating..."):
    for i in range(amount):
        await ctx.send(content)```
upbeat otter
maiden fable
#

Yea

slate swan
prisma spoke
unkempt canyonBOT
#

random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
prisma spoke
maiden fable
#

😐 It's damn easy to make a quiz game istg

upbeat otter
#

thats the easiest way I can provide ,-,

slate swan
#

but its help :/

maiden fable
#

Smh this is the basic logic

prisma spoke
#

🤷

maiden fable
#

🤷‍♂️

prisma spoke
#

await ctx.send(f"<@!{dt[0]}> vs <@!{dt[1]}>")?

#

well it sent the whole as i said

maiden fable
#

???

prisma spoke
prisma spoke
slate swan
#

read it again

prisma spoke
#

oh

maiden fable
#

Cz yr logic is wrong

prisma spoke
# slate swan here
async def brackets(ctx,p:int):
    a = int(p*2)
    data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a,))    
    dataa  = await data.fetchall()
    dt = list(dataa)
    print(data[0] for data in dt)```?
maiden fable
#

answer is a string but bet is an int

prisma spoke
#

this is what u said..?

maiden fable
#

@slate swan

maiden fable
#

Well it depends...

#

What's bet here?

#

They are coins I am sure

#

Yea

#

And u r comparing it to heads/tails

#

Which will always return false and execute the else

#

Understand?

prisma spoke
#
async def brackets(ctx,p:int):
    a = int(p*2)
    data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a,))    
    dataa  = await data.fetchall()
    dt = list(dataa)
    await ctx.send(dt[0])``` how do i get to display only the ids cuz this displays the whole row but i only want the 1st item
maiden fable
#

Uhhhh, u aren't able to understand

slate swan
prisma spoke
#

its a boolean.....

maiden fable
#

U r comparing the number of coins betted to the result of the coin. Suppose u input !coinflip heads 10, then whats the if statement is doing is if 10 == answer where answer is the random.choice

maiden fable
#

U r overwriting the choices variable in 5th line. Fix that, and after that compare choices to answer

maiden fable
#

Yea

#

Wait do one thing

#

The choices variable in the function. Change it to choice

#

Then compare choice and answer

#

Rest everything is correct

slate swan
#

how can i make the bot reply like this?

maiden fable
#

Well in the choices = (...) Line, u r overwriting the user input which makes no sense

worldly bane
maiden fable
slate swan
#

aight thanks

worldly bane
maiden fable
#

Yea

#

Also

#

!code from next time please

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.

shadow wraith
maiden fable
#

No bruv

#

Oh wait nvm

#

Istg slash commands and replies look same

shadow wraith
#

true but slash commands are cooler

maiden fable
#

They are broke

shadow wraith
slate swan
#

is it possible?

prisma spoke
shadow wraith
#

check if that exists

worldly bane
worldly bane
pliant gulch
maiden fable
#

Huh?

shadow wraith
#

why is it ctx.channel.send

#

you could use ctx.send or does that also have no response too

maiden fable
#

ctx.send works

shadow wraith
#

because i could be misunderstanding here

#

and if that doesn't work, use ctx.reply

#

and idk what will work if ctx.send and ctx.reply don't work ¯_(ツ)_/¯

#

have no idea but just check ¯_(ツ)_/¯

#

if ctx.send or ctx.reply works

#

works or no?

maiden fable
#

no

#

that isn't the issue

maiden fable
#

ah wrong

#

u do answer = random.choice() and then compare choice and answer

#

.fetchone() should work else idk I don't work with SQL sorry

shadow wraith
#

choice is what the random module chose im pretty sure

maiden fable
#

choice is the guess the player made

#

!coinflip heads 10 heads is a choice

shadow wraith
#

oh wait

#

i didnt read it ohhh yeah thats why its defined in the params

maiden fable
#

yea

#

Try adding debug print statements

#

print statement in every other line to see which line is working

#

!paste thanks but using a paste would be appericiated

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.

pliant gulch
#

Is there a reason why you're doing random.choice("Heads", "Tails")? `random.choice should be passed a sequence

#

E.g random.choice(["Heads", "Tails"])

slate swan
#

yes that creates a list

maiden fable
#

Ahh my bad

#

Didn't see that. Good catch Andy

pliant gulch
#

Yes

#

!e ```py
import random; random.choice(1, 2)

unkempt canyonBOT
#

Sorry, an unexpected error occurred. Please let us know!

ClientResponseError: 500, message='Internal Server Error', url=URL('http://snekbox.default.svc.cluster.local/eval')

pliant gulch
#

Ok then snekbox

shadow wraith
#

what packages do y'all use to like, make discord buttons

pliant gulch
#

I use my own discord API wrapper

#

😳

shadow wraith
#

damn

worldly bane
shadow wraith
#

hmmm alr

shadow wraith
prisma spoke
#

i want to choose the 1st item from a list and send it

shadow wraith
#

thats literally sql tho

#

oh

#

bru cant you just do something like this

#

!e mylist [1, 2, 3]
print(mylist[0])

unkempt canyonBOT
#

Sorry, an unexpected error occurred. Please let us know!

ClientResponseError: 500, message='Internal Server Error', url=URL('http://snekbox.default.svc.cluster.local/eval')

shadow wraith
#

ugh

prisma spoke
#

not like tht

#

[(808940512979451934, 5, 'd'), (726046274624684034, 2, '2j'), (766217463184228353, 4, 'aa'), (854639229802774538, 2, 'h')] i got this result from sql in list

shadow wraith
#

i understand basic sql

prisma spoke
#

i want to only get the ids from this list

shadow wraith
#

have no idea how to do that

slate swan
prisma spoke
#

kraots the pro of the proest

slate swan
#

Do you not know how to use lists and tuples 😐

prisma spoke
#

[1,2,3] list

slate swan
#

Yes, that's what a tuple is and that's what a list is

slate swan
#

But do you know how to use them

prisma spoke
prisma spoke
pliant gulch
prisma spoke
#

list.append

prisma spoke
slate swan
pliant gulch
#

🤔

prisma spoke
pliant gulch
#

You could use a for-loop and access the first index then

#

Or use a list comp to do the same thing

slate swan
#
lst = [1, 2]
first_elem = lst[0]
# tuples work the same
#

how to make a command that makes my bot leave all servers with under 5 members

prisma spoke
#

WOW

#

i didnt know this is indexing

slate swan
prisma spoke
#

i didnt know the name but ik this

prisma spoke
#

but didnt know what its called...

slate swan
prisma spoke
#

anyways if i do that it returns the 1st tuple

slate swan
#

!d discord.Guild.leave

unkempt canyonBOT
#

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

Leaves the guild.

Note

You cannot leave the guild that you own, you must delete it instead via [`delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.delete "discord.Guild.delete").
prisma spoke
slate swan
slate swan
unkempt canyonBOT
#

property member_count: int```
Returns the true member count regardless of it being loaded fully or not.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.
slate swan
#

I'm not gonna spoonfeed, gave you the logic, gave you the docs to everything you need, the rest is up2u

prisma spoke
slate swan
slate swan
maiden fable
#

;-; bruh

#

Do u even know basic Python?

pliant gulch
#

👁️👄👁️

slate swan
prisma spoke
maiden fable
#

You are laughing on your own mistake ngl

slate swan
#

Ikr

shadow wraith
slate swan
#

kek

maiden fable
#

it should be guild.member_count smh

#

now don't ask me what is guild else I'mma kms

shadow wraith
#

the new discord alternative which i hate

slate swan
maiden fable
#

Ok I am going bye

prisma spoke
slate swan
shadow wraith
#

and later that day he was never seen again :p

maiden fable
slate swan
#

was a joke

prisma spoke
slate swan
shadow wraith
#

how do you import discord_slash.utils.manage_components without an undefined module error

#

only discord_slash.model works to import but what about the message above me

worldly bane
#

he was evading a ban

shadow wraith
#

nuke bots = >:(
nuking scam discord servers = >:)

#

jk nuke is against discord tos but back to discord bots

slate swan
#
@client.commands()
async def servers(self, ctx):
    activeservers = client.guilds
    for guild in activeservers:
        await ctx.send(guild.name)
        print(guild.name)
    await ctx.send(guild.member_count)
shadow wraith
#

you have 2 instances of the bot running

#

oh wait

#

you used ctx.send twice

worldly bane
slate swan
slate swan
worldly bane
slate swan
#

What privacy

#

It's just the guild's name in which the bot is in

#

And the member count

prisma spoke
#
async def brackets(ctx,p:int):
    a = int(p*2)
    data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a,))    
    dataa  = await data.fetchall()
    dt = list(dataa)
    for i in dt[0]:
        await ctx.send(i)``` well now how do i iterate thro like this for the whole list.
#

it sends the id for dt[0]

worldly bane
prisma spoke
#

now do i have to repeat that for dt[1] dt[2]

slate swan
# worldly bane idk privacy?
@client.commands()
async def servers(self, ctx):
    activeservers = client.guilds
    for guild in activeservers:
        await ctx.send(guild.name)
        print(guild.name),(guild.member_count)

feel free to call me stupid, as long as ill get this working ill be happy sadcat

prisma spoke
slate swan
#

And you still did it wrong

prisma spoke
slate swan
#

And you did it wrong, completely the opposite of what I said

prisma spoke
#

this sends the 1st tuple

#

i want the 1st value of the list from the 1st tuple

#

and like that for every thn in th e list

slate swan
pliant gulch
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

slate swan
#

?

prisma spoke
#

i

#

for i

slate swan
#

Isn't that what you want yert

#

i[0]

slate swan
pliant gulch
#

If your bot is verified you need to apply for member intents

maiden fable
#

So I just saw a repo of mine which was dead since 5 months had a PR open from about 25 days ago 😐

slate swan
#

i got banned because someone got mad at people who had default pfps and i defended the person with no pfp, and got banned for provoking arguments

#

very weird situation

worldly bane
jade tartan
#
async def on_member_join(member):
        guild = client.get_guild(730651046459998218)
        channel = await (await client.fetch_channel(885464532959526913)).send(f'Welcome to server **{member.mention}**.')
        role = discord.utils.get(member.guild.roles, name='Unverified')
        roles_list = ["•.¸¸.•:Colours:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•", "•.¸¸.•:Verification:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Age:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Gender:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Sexuality:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
        "•.¸¸.•:Distance:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Ethnicity:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Hobbies:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Relationship:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Location:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
        "•.¸¸.•::•.¸¸.•`Seeking`•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:DM:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Levels:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Games:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•"]
        for roles in roles_list:
            role = discord.utils.get(member.guild.roles, name=roles)
        await member.add_roles(role)
        await member.add_roles(role)
        print(f"{member.name} has joined the server")```
slate swan
jade tartan
#

Hi the auto role Unverified the bot is not assigning it to the member

#

can someone help me

maiden fable
#

why using fetch and not get

slate swan
maiden fable
#

members intent

pliant gulch
pliant gulch
worldly bane
prisma spoke
# slate swan Isn't that what you want <:yert:832277526809149461>
@bot.command()
async def brackets(ctx,p:int):
    a = int(p*2)
    data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a,))    
    dataa  = await data.fetchall()
    dt = list(dataa)
    for i in dt:
        await ctx.send(f"<@!{i[0]}>")``` now how do i do like 2 values shud be sent in one msg...
#

cuz all values are stored together

slate swan
#

??

jade tartan
worldly bane
slate swan
#

Wdym by "together"

prisma spoke
jade tartan
slate swan
#

Send an example where it's sending the way you want

slate swan
pliant gulch
#

I mean, you could avoid this whole problem entirely by doing a SQL query that actually make sense if you only want the IDs

prisma spoke
pliant gulch
#

E.g ```sql
SELECT id FROM users ORDER BY RANDOM() LIMIT ?;

prisma spoke
#

Bru..

slate swan
# prisma spoke f"{1stvalue} vs {2ndvalue}

Add a count and a list, increment it by one with each loop and append the id to the list, check if the count is equal to 2, if it is, then reset the count back to 0 and send the message while also resetting the list to an empty one

jade tartan
#
async def on_member_join(member):
        guild = client.get_guild(730651046459998218)
        channel = await (await client.fetch_channel(885464532959526913)).send(f'Welcome to server **{member.mention}**.')
        roles_list = ["Unverified","•.¸¸.•:Colours:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Verification:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Age:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Gender:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Sexuality:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
        "•.¸¸.•:Distance:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Ethnicity:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Hobbies:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Relationship:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Location:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
        "•.¸¸.•::•.¸¸.•`Seeking`•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:DM:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Levels:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Games:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•"]
        for roles in roles_list:
            role = discord.utils.get(member.guild.roles, name=roles)
        await member.add_roles(role)
        print(f"{member.name} has joined the server")
worldly bane
#

indent await member.add_roles(role) in the for loop

jade tartan
#

But why is there no errors of indent?

#

Ayee it worked thanks

prisma spoke
slate swan
#

No

#

Not helping any further, already told you how to do it, and i won't spoonfeed you

prisma spoke
slate swan
#

Make an int variable and a new empty list variable, when you loop just increment that variable by 1 while appending to the empty list, check with an if statement if it's equal to 2, if it is then send the message, then reset the int variable back to 0, and set the new list back to an empty one

#

Can't be more precise than that

#

Actually you don't even need that int variable, just the list to which you append and check if the length of the list is equal to 2, and then if it is, send the message and empty the list

#

It's really just basic python tbh

#

Which is why I won't help any further with this 👍

jade tartan
#

I need someone to help make something like this

prisma spoke
jade tartan
#

Can someone help?

prisma spoke
slate swan
#

or what

jade tartan
#

await ctx.send(embed=Myembed)

#

its not ctx

prisma spoke
untold token
#

await is keyword that awaits a coroutine/ awaitable

#

Every coro needs to be awaited

jade tartan
#

Its await member.send(embed=Myembed)

jade tartan
prisma spoke
#
    a = []
    for i in dt:
        await ctx.send(f"<@!{i[0]}>")
        f=i[0]
        a.append(f)
        s = 1
        await ctx.send(f"{a[0]} vs {a}")
        a=+s``` @slate swan were u saying smthn like this?
heavy folio
heavy folio
unkempt canyonBOT
#

class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
untold token
# jade tartan

That's an embed that has some files a thumbnail footer and a description and a title

#

You can do all that by constructing the embed

#

Creating fields titles footers and passing the required values in em

heavy folio
untold token
#

and that would raise an error if the member has their dms off

#

or you are not in mutual guilds with them

untold token
jade tartan
#
async def on_member_join(member):
    guild = client.get_guild(730651046459998218)
    channel = client.get_channel(885464532959526913)
    Myembed = discord.Embed(title= f"Welcome"),
    description=(f"Welcome {member.mention}, You are member {guild.member_count}. \n Please enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)"),
    await member.send(embed=Myembed)```
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\thoma\Desktop\discord.py\python\bot.py", line 53, in on_member_join
    await member.send(embed=Myembed)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\dpy_overrides.py", line 350, in send_override
    return await send(channel, *args, **kwargs)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\dpy_overrides.py", line 244, in send
    embeds = [embed.to_dict()]
AttributeError: 'tuple' object has no attribute 'to_dict'```
maiden fable
#

remove the ,

#

from the end

slate swan
maiden fable
#

no lol

visual island
tawdry perch
#

uh, maybe you could loop the dict with highest values?

jade tartan
#
async def on_member_join(member):
    guild = client.get_guild(730651046459998218)
    channel = client.get_channel(885464532959526913)
    Myembed = discord.Embed(title= f"Welcome")
    description=(f"Welcome {member.mention}, You are member {guild.member_count}. \n Please enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)")
    await ctx.send(embed=Myembed)```
How do i let it `await` to the channel?
tawdry perch
#

also not really related to dpy

jade tartan
#

yes channel.send

tawdry perch
#

just do that and should be okay

jade tartan
#

ok question is there an easier way to avoid restarting the bot everytime?

#

and make the new changes

#

code

tawdry perch
#

you have to restart it everytime afaik, otherwise it wont get changes

#

not from me as I have no idea how to do that

#

didn't do anything but you welcome 🤷

full valley
#

I just moved my bot across to another guild, and a check is failing even though it works fine in the original guild.

Any ideas?

#

(A check for a command)

tawdry perch
#

what check is failing?

tawdry perch
full valley
# tawdry perch could you provide a bit more information?
# Checks command issuer not already in a game dictionary
def is_issuer_in_game(ctx):
    piglist = []
    for x in games.values():
        for _ in x:
            piglist.append(_)
    print(piglist)
    print(games.values())
    return ctx.author.id not in piglist

# !q command -> Puts players into queue
@bot.command(name="queue", aliases=["q"], description="Join the queue")
@commands.check(is_issuer_in_game)
@commands.has_any_role(verified_role, 908784013181878342)
async def queue(ctx):

# Handling error if player is already in queue
@queue.error
async def queue_error(ctx, error):
    if isinstance(error, commands.CheckFailure):
        embed = discord.Embed(
            title=f"**You are already in a game**", color=0xE74C3C)
        embed.set_footer(text="CBell 6 Mans | Created by Heptix", icon_url="https://i.imgur.com/1utxX7d.png")
        await ctx.channel.send(embed=embed)

Top is check, bottom is error handler, middle is command.

I printed the piglist and games.values() as shown above in the check, and the list and dict values were empty

[]
dict_values([])
#

I try the command in old guild and it works fine, try it in this one and get hit with the error handler

jade tartan
#

Could you just please let me know what the codes are for account creation of the member and the mention of the member who invited them?

#

if that make sense

tawdry perch
#

member.created_at returns a when it was created, by viewingaudit log you get the invited user

slate swan
slate swan
#

pip3 install psutil

tawdry perch
slate swan
slate swan
#

bro fix the quality cant see shit from that

shadow wraith
#

🤔

#

i just thought of an idea

slate swan
full valley
slate swan
shadow wraith
#
@bot.command(aliases=['the_worst_command_ever'])
async def h(ctx, member: discord.Member):
  if member not in ctx.guild.members:
    await ctx.send("amongus")
  else:
    await ctx.send(f"{member}")
#

would this work? 🤔

tawdry perch
#

should work, looks good to me

shadow wraith
#

so i accidentally made a error handler inside of a command

slate swan
tawdry perch
#

well some sort of error handler, more likely a normal if statement

shadow wraith
#

hmm

tawdry perch
#

but ye it could be a error handler as well

slate swan
#

lol

tawdry perch
#

@slate swan you are making a music bot?

slate swan
#

ya

tawdry perch
#

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

?

#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: create_stage_channel() got an unexpected keyword argument 'bitrate'

tawdry perch
#

code?

jade tartan
tawdry perch
slate swan
#
g=ctx.guild
for cate in g.categories:
                x = await g.create_category(f"{cate.name}")
                for chann in cate.channels:
                    if isinstance(chann, discord.VoiceChannel):
                        await x.create_voice_channel(f"{chann}", bitrate=chann.bitrate, rtc_region=chann.rtc_region, user_limit=chann.user_limit)
                    if isinstance(chann, discord.StageChannel):
                        await x.create_stage_channel(f"{chann}", bitrate=chann.bitrate, user_limit=chann.user_limit, rtc_region=chann.rtc_region, topic=chann.topic, position=chann.position)
                    if isinstance(chann, discord.TextChannel):
                        await x.create_text_channel(f"{chann}", nsfw=chann.is_nsfw(), topic=chann.topic, slowmode_delay=chann.slowmode_delay)```
#

Please don't mind the indentation

#

unreadable code

tawdry perch
#

!paste helps with indent stuff

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.

tawdry perch
#

most of time*

slate swan
#

fix?

tawdry perch
#

I don't even understand what you are doing (no need to explain as I won't understand it)

visual island
#

it doesn't have bitrate arg

maiden fable
slate swan
#

yesh

maiden fable
#

Why

slate swan
#

just i want to try

maiden fable
#

?

slate swan
#

...

maiden fable
#

Uhh so what's the issue?

#

!d discord.Guild.create_voice_channel

unkempt canyonBOT
#

await create_voice_channel(name, *, reason=None, category=None, position=..., bitrate=..., user_limit=..., rtc_region=..., video_quality_mode=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

This is similar to [`create_text_channel()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.create_text_channel "discord.Guild.create_text_channel") except makes a [`VoiceChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceChannel "discord.VoiceChannel") instead.
slate swan
#

error above

maiden fable
#

!d discord.Guild.create_stage_channel it doesn't have a bitrate kwarg

unkempt canyonBOT
#

await create_stage_channel(name, *, topic, position=..., overwrites=..., category=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

This is similar to [`create_text_channel()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.create_text_channel "discord.Guild.create_text_channel") except makes a [`StageChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.StageChannel "discord.StageChannel") instead.

New in version 1.7.
slate swan
#

OK so I finished my lunch, @maiden fable @visual island

#

It has bitrate tag

slate swan
#

Oh I got the answer to my question

junior verge
#

How would you make a command like !invite 1 that you would generate a 1 invite link

boreal ravine
#

@slate swan

tawdry perch
#

!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 the [`create_instant_invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_instant_invite "discord.Permissions.create_instant_invite") permission to do this.
slate swan
boreal ravine
#

no ban 🙏

slate swan
#

!ban @boreal ravine random pings

tawdry perch
boreal ravine
slate swan
#

:kek:

boreal ravine
#

wait you can't talk right

#

hm

vocal plover
#

I must now ban you both from nextcord for random pings 😔 /s

boreal ravine
junior verge
#
import discord
from discord.ext import commands
import datetime

class Invite(commands.Cog):

    def __init__(self, client):
        self.client = client

    @commands.command(pass_context = True)
    async def invite(ctx, userToInvite):
            inviteLinq = await ctx.create_invite(destination = ctx.message.channel, xkcd = True, max_uses = 1)
            await ctx.send_message(userToInvite, inviteLinq)

def setup(client):
    client.add_cog(Invite(client))
``` won't this work
boreal ravine
#

send_message isn't an attribute

#

in commands.Context

junior verge
#

What should it be though

boreal ravine
#

create_invite

junior verge
#

ctx.send?

boreal ravine
#

isnt even a thing in commands.Context

vocal plover
#

And whats the xkcd kwarg lol

#

I need this whatever it is

boreal ravine
unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
junior verge
#

I dont know I was just looking for something and seeing if it works man

#

I have no clue on how to make what I want

boreal ravine
boreal ravine
junior verge
#

Yeah alright

#

So I want to make a command for people that do not have invite permissions that would be .invite and it would generate a 1 use invite link, also in a embed etc but that won't matter at first

boreal ravine
junior verge
#

To the server you are typing the command in

boreal ravine
#

!d discord.TextChannel.create_invite please don't use the class name, use an instance of it, Context.channel you can make everything empty and just call the function without any kwargs iirc

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 the [`create_instant_invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_instant_invite "discord.Permissions.create_instant_invite") permission to do this.
junior verge
boreal ravine
junior verge
#
@client.command(pass_context=True)
async def invite(ctx, time_in_seconds,uses):
    invitelink = await discord.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=uses,max_age=time_in_seconds)
    await ctx.send(invitelink)
``` I got this now this is kinda what I want but not really
boreal ravine
#

to a channel (the server)

boreal ravine
junior verge
#

What's wrong with it?

boreal ravine
junior verge
#

Yeah

#

btw how do you do this any idea

boreal ravine
#

that should work ig, btw remove pass_context lol

junior verge
#

okay

boreal ravine
junior verge
#

ah interactions

boreal ravine
#

yes

junior verge
#

but how would I make the command so it always would make a 1 use link for 1 week

boreal ravine
#

@tawdry perch rip.

tawdry perch
#

indeed

junior verge
#

uhm like this?

@client.command()
async def invite(ctx, time_in_seconds,uses):
    invitelink = await discord.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=1,max_age=604800)
    await ctx.reply(invitelink)
tawdry perch
#

I absolutele did not join to view the server

boreal ravine
#

also remove time_in_seconds/uses lol, kinda useless rn

tawdry perch
boreal ravine
#

lol

slate swan
#

:kek:

tawdry perch
#

moves to alt account

junior verge
#
import discord
from discord.ext import commands
import datetime
print('invite')

class Invite(commands.Cog):

    def __init__(self, client):
        self.client = client

    @commands.command()
    async def invite(ctx):
        invitelink = await discord.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=1,max_age=604800)
        await ctx.reply(invitelink)
        print('invite2')
    
    
def setup(client):
    client.add_cog(Invite(client))
``` why doesn't the cog work
junior verge
#

oooooo ofc

#

my bad

boreal ravine
#

or you didnt load the cog

junior verge
#

Yeah no I forgot self

modest plover
#

I've tried resetting all of Termux' data, that didn't work

#

I tried on multiple connections, none of them work

junior verge
#

nvm

tawdry perch
#

did you just copy out the discord.abc.GuildChannel?

junior verge
#

What?

#
    @commands.command()
    @has_permissions(manage_messages=True)
    async def invite(self, ctx):
        invitelink = await discord.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=1,max_age=604800)
        await ctx.reply(invitelink)
        print('invite2')
``` no I am trying to get the has permissions work
tawdry perch
#

it should not work with discord.abc.GuildChannel afaik

junior verge
#

import has_permissions, CheckFailure py right

tawdry perch
#

really?

junior verge
tawdry perch
#

I did not know that ;-;

junior verge
#

thats not the problem

#

all good

boreal ravine
junior verge
boreal ravine
#

show

junior verge
#
@commands.command()
    @has_permissions(manage_messages=True)
    async def invite(self, ctx):
        invitelink = await discord.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=1,max_age=604800)
        await ctx.reply(invitelink)
        print('invite2')

    @invite.error
    async def invite_error(error, ctx):   
        if isinstance(error, MissingPermissions):
            await ctx.send("You don't have permission to do that!")
tawdry perch
#

just do commands.has_permissions?

boreal ravine
#

import it from dpy commands extension

junior verge
#

what do you mean

boreal ravine
junior verge
#

on the same line you mean

boreal ravine
#

yes

#

use from keyword

junior verge
#
import discord
from discord.ext import commands import has_permissions, CheckFailure  
import datetime
#

not like that right

boreal ravine
junior verge
#

how then huh

#

done

boreal ravine
#

try again now

slate swan
#
@client.command()
@commands.is_owner()
async def leaveguild(ctx, *, guild: discord.Guild):
    await guild.leave()
    await ctx.send(f"I've left {guild.name}!")
#

says command leaveguild isn't found
discord.ext.commands.errors.CommandNotFound: Command "leaveguild" is not found

slate swan
junior verge
#

whats this

#

my error command is not working

#
@invite.error
    async def invite_error(error, ctx):   
        if isinstance(error, MissingPermissions):
            await ctx.send("You don't have permission to do that!")
boreal ravine
unkempt jewel
junior verge
boreal ravine
unkempt jewel
#

help me

boreal ravine
#

istg it existed, brb

vocal plover
#

just commands.has_permissions

junior verge
#

how do i define missing permissions

unkempt jewel
junior verge
boreal ravine
#

!d discord.ext.commands.bot_has_permissions

unkempt canyonBOT
#

@discord.ext.commands.bot_has_permissions(**perms)```
Similar to [`has_permissions()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.has_permissions "discord.ext.commands.has_permissions") except checks if the bot itself has the permissions listed.

This check raises a special exception, [`BotMissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BotMissingPermissions "discord.ext.commands.BotMissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
boreal ravine
#

why is it

#

hm

boreal ravine
slate swan
boreal ravine
unkempt canyonBOT
#

exception discord.ext.commands.MissingPermissions(missing_permissions, *args)```
Exception raised when the command invoker lacks permissions to run a command.

This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
boreal ravine
unkempt jewel
junior verge
#
import discord
from discord.ext import commands 
from discord.ext.commands import MissingPermissions import has_permissions, CheckFailure 
import datetime
``` how do I list this correctly
boreal ravine
junior verge
#

correct order

slate swan
#

use , instead of import before has_permissions

#

Order doesn't matter

boreal ravine
#

o

#

what sarthak said, it's like making an array

junior verge
unkempt jewel
vocal plover
#

the variable l

junior verge
boreal ravine
unkempt jewel
boreal ravine
vocal plover
#

oh yeah kayle thats part of dpy

#

look at the trace

slate swan
unkempt jewel
#

MODERATION

@client.command()
@commands.has_permissions(manage_messages = True)
async def clear(ctx, amount = int):
await ctx.channel.purge(limit = amount)

vocal plover
#

amount: int

vocal plover
#

by setting amount to int you're setting it to the type of int

#

rather than hinting that it should be one

unkempt jewel
#

thanks

boreal ravine
tidal hawk
#

Out of curiosity, can bot's share screen?

vocal plover
#

no

tidal hawk
#

would be amazing

#

imagine a bot, which broadcasts some events

#

or personal tv

vocal plover
#

would be a legality nightmare Kek

tidal hawk
#

!channel 2

slate swan
#
async def on_raw_reaction_add(payload: discord.RawReactionActionEvent):

With this function, how can I check if a user has specific roles. E.G if user has role named "muted", return true

maiden fable
unkempt canyonBOT
#

class discord.RawReactionActionEvent```
Represents the payload for a [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") or [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") event.
boreal ravine
#

what's the diff between on_raw events and the normal ones?

maiden fable
#

!d discord.RawReactionActionEvent.user_id

unkempt canyonBOT
maiden fable
#

Use this (:

maiden fable
kindred drum
#
AttributeError: 'Message' object has no attribute 'payload'```
#

anyone got a solution?

#
memberid = await channel.fetch_message(payload.message_id)
            await memberid.payload.send(f"Your reputation was deleted, it could be for the following reasons: 1. 2. 3. To prevent this from happening again, make sure your reputation is VALID")
           ```
maiden fable
#

message.channel.send*

maiden fable
boreal ravine
#

reaction, user, payload ig

junior verge
#
@commands.command()
    @has_permissions(manage_messages=True)
    async def invite(self, ctx):
        invitelink = await discord.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=1,max_age=604800)
        embed=discord.Embed(title="Your invite link!",description=f"(invitelink)", color=0xFF5733)
        await ctx.reply(embed=embed)
        print('invite2')
``` how would I make it so it sends the (invitelink) in the desc of the embed
tawdry perch
boreal ravine
#

!f-strings

unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

full valley
#
# !substitute command -> Subs a player in if a q has popped
@bot.command(name="substitute", aliases=["sub"], description="Sub a player in")
@commands.has_any_role(staff_role, "Developer")
async def substitute(ctx, thegameid, oldplayer: discord.User, newplayer: discord.User):
    if ctx.channel.id in allowed_channels:
        try:
            gameid = int(thegameid)
            index = games[gameid].index(oldplayer.id)
            games[gameid][index] = newplayer.id
            if oldplayer.id in team1_ids[gameid]:
                print(team1_ids)
                index1 = team1_ids[gameid].index(oldplayer.id)
                team1_ids[gameid][index1] = newplayer.id
                embed = discord.Embed(
                    description=f"**{newplayer.mention} has been swapped in for {oldplayer.mention} on team 1**",
                    color=0x00FF00)
                embed.set_footer(text=f"Authorised by {ctx.author.name} | CBell 6 Mans | Created by Heptix", icon_url="https://i.imgur.com/1utxX7d.png")
                print(team1_ids)
            if oldplayer.id in team2_ids[gameid]:
                print(team2_ids)
                index2 = team1_ids[gameid].index(oldplayer.id)
                team2_ids[gameid][index2] = newplayer.id
                embed = discord.Embed(
                    description=f"**{newplayer.mention} has been swapped in for {oldplayer.mention} on team 2**",
                    color=0x00FF00)
                embed.set_footer(text=f"Authorised by {ctx.author.name} | CBell 6 Mans | Created by Heptix", icon_url="https://i.imgur.com/1utxX7d.png")
                print(team2_ids)
            else:
                await ctx.message.add_reaction('❌')
            await ctx.channel.send(embed=embed)
        except Exception:
            print(traceback.format_exc())
            ctx.message.add_reaction('❌')
``` How come its adding a cross and also sending the embed?
cloud dawn
#

Anyone in the snowgiving server?

tawdry perch
#

In the what?

cloud dawn
#

This but it's full i'm curious about the new features

vocal plover
#

i joined and my client crashlooped sunglas

cloud dawn
#

Or is it just the activity stuff from Discord

vocal plover
#

also the server is now full

cloud dawn
#

prob

full valley
cloud dawn
#

Yeah pretty sure they putted a cap on it.

cloud dawn
tawdry perch
cloud dawn
tawdry perch
#

800k members ;-;

cloud dawn
#

Pretty sure it caused this spike lol

tawdry perch
#

maybe

#

imagine this server with 800k members

maiden fable
slate swan
#
    for i in range(0,len(Json_Items)): #It doesn't exist
        for x in Json_Items[i]:
            if int(x) == int(member.id):
                print(x)
                del Json_Items[i][x]
                json.dump(Json_Items, open("./all_user_rep.json", "w"), indent=1)
                return

Anyone know how to fix this leaving:
[
{}
]
in the JSON

spring flax
#

Why?

cloud dawn
spring flax
#

Ah well the VC games feature is now implemented there for one

maiden fable
#

O

spring flax
#

The server is too laggy i cant scroll down on channels or click them

cloud dawn
full valley
cloud dawn
#

I think the VC games are pretty great.

maiden fable
#

Lmfao discord is like: Welp everyone adding unadded features even before we added them, so let's stop verifying bots with these features

cloud dawn
full valley
#

Yeah

cloud dawn
maiden fable
cloud dawn
#

And have the game id.

cloud dawn
maiden fable
#

I am just saying, suppose my bot HunAI has that feature... Then discord would deny the verification

cloud dawn
#

Ohh in that sense.

maiden fable
#

Yea

cloud dawn
#

Well i think that's fair since they allowed Discord bot devs to showcase it not release it beforehand.

maiden fable
#

Facts

cloud dawn
#

disnakeeee :)

maiden fable
#

So rn, there is no way to save the Invite object, right?

maiden fable
cloud dawn
#

In the cache?

maiden fable
#

Instead of calling the API again and again

cloud dawn
maiden fable
#

Like saving guild.invites

maiden fable
cloud dawn
#

What db are you using?

maiden fable
#

Well u can tell me of any db

#

I ain't saving, just a general talk

cloud dawn
#

Because i don't think any sql based db allows to store objects only datetime.

maiden fable
cloud dawn
#

What do you need to store from that object?

maiden fable
#

But, if discord.py made the JSON received from the API, an instance variable, then we could just have got the raw JSON with invite.data and store the dict, and manually convert it to an Invite object, but in here https://github.com/DisnakeDev/disnake/blob/master/disnake/invite.py#L352-L370 the lib is directly getting the keys

GitHub

An API wrapper for Discord written in Python. Contribute to DisnakeDev/disnake development by creating an account on GitHub.

cloud dawn
#

You could just add another table and inner join it using the guild id.

maiden fable
#

?

cloud dawn
#

Fetch that and cache the db result by remaking the object.

maiden fable
#

My question is, how to "store" the discord.Invite object to the db

maiden fable
#

It will become just like getting the JSON from the API and then parsing it

slate swan
maiden fable
#

Just we are fetching it from the DB instead of the API

cloud dawn
#

ok maby 10x

slate swan
maiden fable
cloud dawn
maiden fable
cloud dawn
slate swan
#

tired of closing and running it agin

cloud dawn
maiden fable
unkempt canyonBOT
#

reload_extension(name, *, package=None)```
Atomically reloads an extension.

This replaces the extension with the same extension, only refreshed. This is equivalent to a [`unload_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.unload_extension "discord.ext.commands.Bot.unload_extension") followed by a [`load_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension") except done in an atomic way. That is, if an operation fails mid-reload then the bot will roll-back to the prior working state.
slate swan
#

he wants to reload the entire bot not a cog

#

yeah

cloud dawn
#

But why..?

maiden fable
#

¯_(ツ)_/¯

cloud dawn
#

I'd still refer you to cogs, or tell us exactly what it is you are trying to reload.

slate swan
#

the entire bot

cloud dawn
#

Like a command or event, or the actual Bot source.

maiden fable
#

Bruh

#

Also u know... Restarting bot too much isn't recommended

#

All your cache would be destroyed if u restart it

slate swan
#

oh

maiden fable
#

It's just like u manually starting and stopping it

#

That's why we are saying to use cogs

full valley
#

What are the benefits of using the cache though

cloud dawn
#

Henche why i'm asking if it is really necessary yeah i know a way and hunter prob does too but why..?

vocal plover
#

if you want it to auto update then the best way would be something like kubernetes deployment using github actions

grim oar
cloud dawn
vocal plover
#

else something like pm2 with an update script

maiden fable
gray gazelle
#

what are the pros of using discord.ext.commands.AutoShardedBot?

maiden fable
#

The data is stored in the RAM (memory), so faster exchange

maiden fable
full valley
#

ah

cloud dawn
grim oar
vocal plover
#

autoshardedbot doesnt us multiple processes

maiden fable
#

O

vocal plover
#

it just opens multiple websockets on the same process

cloud dawn
#

Sadly

maiden fable
#

Ah

grim oar
#

What's sad in it shipit

maiden fable
#

So like, it connects more than one time to the discord websocket?

vocal plover
#

unless you have like 10k servers you probably dont need to be on more than one process tbh

maiden fable
#

What's the advantage of that tho?

vocal plover
#

maybe if you're handling presence updates

grim oar
maiden fable
#

O

cloud dawn
vocal plover
#

autosharded is just a different local client

#

it cant change ratelimits

maiden fable
#

So Auto sharded has static ratelimit?

#

That's what u mean?

grim oar
#

No

maiden fable
#

"It can't change ratelimits"

cloud dawn
vocal plover
#

what would that change?

cloud dawn
grim oar
vocal plover
#

no that would be terrible design

#

people would just use proxies to spam requests

cloud dawn
#

Okay so if i got a bot that is in 500k guilds that would make a lot more api calls than a bot that has 1k bots. Does Discord look at the user & guild count? (Just curious rooPopcorn )

cloud dawn
faint monolith
#

I wanna get back my scripts from heroku. What should I do?

faint monolith
#

How can I download them

slate swan
#

i know this is possible is discord.js but is making the activity change constantly possible to do in discord.py as well? if so how?

cloud dawn
cloud dawn
slate swan
#

i saw a bot changing it and thought it looked cool

cloud dawn
faint monolith
cloud dawn
faint monolith
#

???

slate swan
cloud dawn
slate swan
cloud dawn
full valley
#

Guys big problem lol

slate swan
cloud dawn
full valley
#

I just installed node and npm

#

sudo apt-get install npm
sudo apt-get install nodejs

how can I delete them now

cloud dawn
cloud dawn
slate swan
cloud dawn
full valley
#

SHould I reinstall the server?