#discord-bots

1 messages · Page 456 of 1

pliant gulch
#

Gets VSC setup for python coding

empty quartz
#

i already have python but when i run the code it says discord not found or something.

pliant gulch
#

Refer back to this then

#

I'd assume vsc is using the wrong python version. That is if you have already installed discord.py in the first place

empty quartz
#

Ok.

pliant gulch
#

Unless I'm mistaking what you are saying this extension is not discord.py

outer violet
#

How do you make a verification system where a user has to type in the command so they have access to the rest of the server?

boreal ravine
slate swan
#

hey anyone know how i can restrict a command to a specific user and a specific channel at the same time?

pure reef
#

how do i get the single missing argument??

slate swan
#

is there a rough estimate on how long i can keep using discordpy to develop bots

#

ah wait, pins

#

is there a event called when a user leaves a voice channel

agile goblet
tulip oracle
#

can i compare a user object gained by fetch_user to members in bans() list
since im checking for it, but errors that the user isnt there when he is

slate swan
agile goblet
#

items in the bans() list are BanEntry objects

#

not user object

#

BanEntry.user exists however

tulip oracle
#

something like await guild.bans().BanEntry(user) ? @agile goblet

slate swan
pure reef
#

how to do reply?

slate swan
#

ctx.reply

#

its just like ctx.send

pure reef
#

glooks

slate swan
#

except not send its reply

pure reef
#

ight

reef shell
#

if you don't want to mention the author then ctx.reply("blah", mention_author = False)

agile goblet
#

each object has the attribute user so you can get the User object instead

#

either iterate over it or use an index

slate swan
#

Hi

slate swan
#

@slate swanyea

#
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.ReportAnswers' raised an error: AttributeError: module 'discord.ext.commands' has no attribute 'cogs'
#

Try Cogs

#

Not cogs

#
File "C:\Users\Danny\AppData\Local\Programs\Python\Python39\lib\importlib\util.py", line 94, in find_spec
    parent = __import__(parent_name, fromlist=['__path__'])
ModuleNotFoundError: No module named 'Cogs'
#

!d discord.ext.commands.Cog

unkempt canyonBOT
#

class discord.ext.commands.Cog```
The base class that all cogs must inherit from.

A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/stable/ext/commands/cogs.html#ext-commands-cogs) page.

When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
slate swan
#

?

stark hearth
#
    @commands.command(aliases=['p'])
    async def play(self, ctx, url):
        ctx.voice_client.stop()
        FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
        YDL_OPTIONS = {'format':"bestaudio"}
        vc = ctx.voice_client

        with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
            info = ydl.extract_info(url, download=False)
            url2 = info['formats'][0]['url']
            source = await discord.FFmpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
            vc.play(source)

i am trying to play url's from my bot but it appears as a command invoke error

#

anything wrong?

slate swan
#

You may be doing wrong

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

@slate swan

#

Not called Cogs?

#

Am i supposed to import Cogs from discord.ext?

slate swan
#

Lemme

#

Import-

#

Yep

#

From commands import Cog

#

Right?

#

From discord.ext.commands import Cog yes

#

@slate swan

#

Yeah

#

@slate swan

pure reef
#

await ctx.reply isnt working

pallid meadow
#

can you show your code?

slate swan
pure reef
winged mural
#

Hello,
Is slash commands now available with python ?

pallid meadow
#

they have not been released and will never be released because discord.py is deprecated

winged mural
#

😮

pure reef
#

so no idea?

pallid meadow
#

but there are 3rd party library's that offer slash command support

pallid meadow
winged mural
pure reef
#

it was working then i changed it to await ctx.reply() from await ctx.send()

#

its not a big deal tho

pallid meadow
#

oh

#

I don't think you can reply to a message with buttons

#

if that makes sense

pallid meadow
#

I haven't used it but I have heard others say it's pretty good

pure reef
#

what should i do to make it look better ?

#

i feel like the "Moderation Commands" part is to bland

pallid meadow
#

Well I mean you could get rid of those labels as you don't really need them since they are already in the dropdown menu

pure reef
#

how can i make like a big black box using `

#

`welcome

#

welcome

pallid meadow
#

so you would use 3 ticks

pallid meadow
#

if you're trying to do a multi line code block

#
do
you
mean
like
this?

@pure reef

pure reef
#

mhm

pallid meadow
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

pure reef
#

okay thx

pallid meadow
#

So you would just use 3 tick marks

nocturne lake
#

would hikari require a full rewrite?

pallid meadow
#

and don't add the py because that will add syntax highlighting

pallid meadow
nocturne lake
pure reef
#

looks way better

nocturne lake
#

well syntax ain't the right word, I meant different functions, parameters etc

pallid meadow
#

Why would it require a rewrite though?

nocturne lake
#

point taken

winged mural
#

@pallid meadow Do you know what is the best framework to use to create a bot not necessarily in python that's maintained ?

pure reef
#

anyone here use sqlite3 that can help me make welcome channels for multiple guilds so i can get out of the habit of using configs

winged mural
#

I have already make a bot with discord.py but now deprecated, i'm so sad :/

final iron
#

I'm getting kind of burnt out with coding my bot. Are there any ways I can keep myself motivated?

stark hearth
final iron
#

Tbh I just have no idea what to do

#

I was planning on making an audio play command but thats not allowed anymore

tulip oracle
#

keep getting error
Command raised an exception: AttributeError: 'User' object has no attribute '_roles'
which i dont get since im not affiliating with that attr

pure reef
#

how do i get the number of lines from a txt file

tulip oracle
pure reef
#

literally never tried it before so i have no clue what u meant

dapper cobalt
#

!d discord.User

unkempt canyonBOT
#

class discord.User```
Represents a Discord user.

`x == y` Checks if two users are equal.

`x != y` Checks if two users are not equal.

`hash(x)` Return the user’s hash.

`str(x)` Returns the user’s name with discriminator.
tulip oracle
tulip oracle
pure reef
#

all im thinking of is: `with open ("cmds.txt") as f:

tulip oracle
#

?

pure reef
#

then the rest

#

cuz i dont understand what your saying

tulip oracle
#

thats basics of working with a file in python yes

pure reef
#

kinda new so

dapper cobalt
tulip oracle
dapper cobalt
#

Ah alright then.

pure reef
#

is there an easier way to do it if i have it in the main.py file like
commands = {

 "cmd1"
  "cmd2"

}

#

is there a way i can get how many of those there are more easily

dapper cobalt
unkempt canyonBOT
tulip oracle
pure reef
#

im just trying to get a way to see how many commands i have

pallid meadow
pure reef
#

i used to have one but i forget

keen talon
tulip oracle
dapper cobalt
pure reef
#

thats what it is

#

thanks

dapper cobalt
#

No problem. potatopat

tulip oracle
#

i dont think theres anyway i can pull this off then

pallid meadow
#

but node is pretty good

winged mural
maiden fable
#

See the message I replied to

pallid meadow
#

I can give you a 3rd party library that you would use along side discord.py

keen talon
#

I am thinking of learning game dev now dogdance

broken turtle
#

!autodelete

visual island
tulip oracle
#

how can i except a commands.MemberNotFound ?

broken turtle
#

!d await message.delete

unkempt canyonBOT
pallid meadow
#

you would just have a try and except

#

@tulip oracle

keen talon
broken turtle
#

bruh

unkempt canyonBOT
#

discord.on_command_error(ctx, error)```
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.

A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
broken turtle
#

hey

winged mural
pallid meadow
#
try:
  #code
except discord.MemberNotFound:
  #code

@tulip oracle

broken turtle
#

hey how do you make it so the bot deletes its message when a command is executed

pallid meadow
#

ctx.delete

keen talon
broken turtle
#
@bot.command(aliases=['c'])
@commands.has_permissions(manage_messages = True)
async def clear(ctx,amount=1):
    await ctx.channel.purge(limit = amount)
    embed = discord.Embed(
        title= f":x: Purge command issued",
        description = f'{ctx.author.mention} cleared {amount} messages',
        colour= discord.Color.green())
    await ctx.send(embed=embed)
async def on_message(ctx):
    await message.delete()
#

i did this wrong

tulip oracle
pallid meadow
broken turtle
#

so @bot.event?

pallid meadow
#

so in your clear function you would do something like

@bot.command(aliases=['c'])
@commands.has_permissions(manage_messages = True)
async def clear(ctx,amount=1):
    await ctx.delete()
    # code
tulip oracle
#

ctx.message.delete() iirc no?

broken turtle
#

ohhh

pallid meadow
#

I think ctx.delete works too

#

let me check

broken turtle
#

imtesting

#

didnt work

prime bane
#

waoh

pallid meadow
keen talon
broken turtle
#

maybe if i pute await ctx.delete(embed=embed)

pallid meadow
#

No that won't work

broken turtle
pallid meadow
#

@broken turtle do await ctx.message.delete()

broken turtle
#

alright

keen talon
#

lol I was chatting here thinking this was ot

thorny cliff
#

Can I create an Error class that I raise and it sends a message in a channel?

#

ie can I raise an error asyncronously

broken turtle
keen talon
#

on_command_error

broken turtle
#

got this after adding await ctx.message.delete

broken turtle
#

how is the message unknown

broken turtle
#

interesting error indeed

keen talon
thorny cliff
# keen talon `on_command_error`

I could create Errors, run a function, if some condition happens I raise the error, the try block catches it, but it does stuff when there's an error? Or what, like does oncommanderror just work with discord commands related errors or hmmm

broken turtle
#
@bot.command(aliases=['c'])
@commands.has_permissions(manage_messages = True)
async def clear(ctx,amount=1):
    await ctx.channel.purge(limit = amount)
    embed = discord.Embed(
        title= f"❌ Purge command issued",
        description = f'{ctx.author.mention} cleared {amount} messages',
        colour= discord.Color.green())
    await ctx.send(embed=embed)
    await ctx.message.delete()
thorny cliff
#

I could google on_command_error instead of asking to save your time lol okay I'll do that now and let you know if I got trouble

keen talon
thorny cliff
#

Okok that makes sense

broken turtle
maiden fable
keen talon
#

!d discord.on_command_error

unkempt canyonBOT
#

discord.on_command_error(ctx, error)```
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.

A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
keen talon
#

didn't think of that

broken turtle
#

i want the bot to delete its own message

maiden fable
#

ctx.message refers to the command message

broken turtle
#

so

#

bot.message?

maiden fable
#

Use the delete_after kwarg in the send() method

keen talon
maiden fable
#

send(delete_after=3)

broken turtle
#

confused

crude crater
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

crude crater
#
@client.command
async def userinfo(self, ctx, target: Optional[Member]):
    target = target or ctx.author

    embed = Embed(title="User information",
                      colour=target.colour,
                      timestamp=datetime.utcnow())

    embed.set_thumbnail(url=target.avatar_url)

    fields = [("Name", str(target), True),
          ("ID", target.id, True),
          ("Bot?", target.bot, True),
          ("Top role", target.top_role.mention, True),
          ("Status", str(target.status).title(), True),
          ("Activity", f"{str(target.activity.type).split('.')[-1].title() if target.activity else 'N/A'} {target.activity.name if  target.activity else ''}", True),
          ("Joined at", target.joined_at.strftime("%d/%m/%Y %H:%M:%S"), True),
          ("Boosted", bool(target.premium_since), True)]

    for name, value, inline in fields:
            embed.add_field(name=name, value=value, inline=inline)

        await ctx.send(embed=embed)
#

it says inconsistent use of tabs and spaces but theres not can someone double check?

broken turtle
#

i was gonna say

maiden fable
broken turtle
#

shoudl jsut be ctx, target

maiden fable
#

Indeed

crude crater
broken turtle
#

oh

boreal ravine
#

@crude crater Try to reindent the command

broken turtle
#

🤢

boreal ravine
#

Maybe that'll work

crude crater
#

even when i type tabs, it makes them spaces

crude crater
boreal ravine
#

u type tabs?

crude crater
#

yes

boreal ravine
crude crater
#

yk what i mean lol

#

and no theyre only 2

boreal ravine
#

just reindent it

#

try and see

crude crater
#

i tried, it makes them spaces

boreal ravine
boreal ravine
crude crater
boreal ravine
crude crater
boreal ravine
#

reindent the command

crude crater
#

my problem

keen talon
crude crater
boreal ravine
#

unindent the command

#

then reindent it

crude crater
#

i did that

#

and it dont work

boreal ravine
#

why dont it work

crude crater
#

it just dont work

#

it gives me the same error or wtv

visual island
boreal ravine
#

Try it and see

crude crater
#

im telling you, i did

#

i unindented

#

reindented

#

tried it again

#

and no worky

boreal ravine
#

u said u didnt know how to reindent a command

crude crater
#

you said to unindent so i deleted the indents

#

and then put them back

maiden fable
boreal ravine
#

@crude crater Change the indent size to 4

broken turtle
#
@bot.command(aliases=['c'])
@commands.has_permissions(manage_messages = True)
async def clear(ctx,amount=1):
    await ctx.channel.purge(limit = amount+1)
    embed = discord.Embed(
        title= f":x: Purge command issued",
        description = f'{ctx.author.mention} cleared {amount} messages',
        colour = discord.Color.green())
    await ctx.send(embed=embed)
    await ctx.channel.purge(limit = amount)

i added await ctx.channel.purge(limit = amount) and it works

maiden fable
#

Yea

boreal ravine
#

yes

broken turtle
#

im smort

boreal ravine
#

@crude crater By default replit changes indents to 2 spaces and not 4. The default is 4. Change it and reindent it again

crude crater
#

i changed it to 4

#

and still no worky

worn tapir
#

Can I make a Discord bot that regularly changes my status message? For example, I can feed it a list of strings and it would pick one at random and set my status to it? I know how to do the random message part, but not actually assigning a message.

crude crater
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

pure reef
#

selfbot?

maiden fable
#

You can't change your status with a bot@worn tapir

worn tapir
boreal ravine
#

yes

maiden fable
#

They can do many things but that's one of them, yes

crude crater
#

fields = [("Name", str(target), True),

#

how is this an invalid syntax?

boreal ravine
#

@crude crater y not just make a default embed

crude crater
undone wyvern
boreal ravine
#

he doesnt

crude crater
#

fields = [("Name", str(target), True),
("ID", target.id, True),
("Bot?", target.bot, True),
("Top role", target.top_role.mention, True),
("Status", str(target.status).title(), True),
("Activity", f"{str(target.activity.type).split('.')[-1].title() if target.activity else 'N/A'} {target.activity.name if target.activity else ''}", True),
("Joined at", target.joined_at.strftime("%d/%m/%Y %H:%M:%S"), True),
("Boosted", bool(target.premium_since), True)]

boreal ravine
#

he has a closing bracket at the end

crude crater
#

the bracket already closed at the end

broken turtle
#

i have no idea how to put a time interavl inmy mute command

#
@bot.command()
@commands.has_permissions(manage_roles = True)
async def mute(ctx, user : discord.Member,*,reason= "No reason provided idot"):
    roleobject = discord.utils.get(ctx.message.guild.roles, id=870577969477857289)
    await user.add_roles(roleobject)
    await user.send("You have been muted in **Aurora  | Social • Icons • Anime** because:"+reason)
    await user.mute(reason=reason)
    await ctx.send(f":white_check_mark: {user} was muted") 
boreal ravine
#

@broken turtle y put it manually

broken turtle
#

well yes

#

lmfao

crude crater
# broken turtle ```py @bot.command() @commands.has_permissions(manage_roles = True) async def mu...
@client.command(description="Mutes the specified user.")
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member, *, reason=None):
    guild = ctx.guild
    mutedRole = discord.utils.get(guild.roles, name="Muted")

    if not mutedRole:
        mutedRole = await guild.create_role(name="Muted")

        for channel in guild.channels:
            await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)

    await member.add_roles(mutedRole, reason=reason)
    await ctx.send(f"Muted {member.mention} for reason {reason}")
boreal ravine
crude crater
#

just use that brotha man

boreal ravine
#

bruh

pure reef
boreal ravine
#

no spoonfeeding

#

@pure reef why 1.6 and not 1.7.3

crude crater
#

bro who cares lmao

pure reef
#

idk i use 1.6

supple storm
#
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\luffy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\luffy\Desktop\All Things\Code File\Python\Discord.py\MineHardcore.py", line 165, in on_message
    if Member.mention in message.content:
AttributeError: 'NoneType' object has no attribute 'mention'
boreal ravine
supple storm
#

help me

crude crater
pure reef
#

not an on_message

crude crater
#

and im trying to help them

broken turtle
#

wait i though of soemthing

crude crater
#

if they want to learn they just wont use it

supple storm
maiden fable
pure reef
#

r u making a command ?

#

what's benefits of using 1.7 instead of 1.6

boreal ravine
supple storm
maiden fable
#

Some new features, many bug fixes

supple storm
#

not command

pure reef
supple storm
#

how to fix??

pure reef
#

there i got 1.7.1

boreal ravine
#

1.7.3

pure reef
#

ugh

supple storm
#

help me pls

broken turtle
#

bruh my command works but i get this

boreal ravine
#

what are u tryna do @supple storm

broken turtle
#
@bot.command()
@commands.has_permissions(manage_roles = True)
async def mute(ctx, user : discord.Member,*,reason= "No reason provided idot", unit = None):
    roleobject = discord.utils.get(ctx.message.guild.roles, id=870577969477857289)
    await user.add_roles(roleobject)
    if unit == "s":
        wait = 1 * duration
        time.sleep(wait)
    elif unit == "m":
        wait = 60 * duration
        time.sleep(wait)
    await user.send("You have been muted in **Aurora  | Social • Icons • Anime** because:"+reason)
    await user.mute(reason=reason)
    await ctx.send(f":white_check_mark: {user} was muted for {duration}") 
boreal ravine
broken turtle
#

lmao

boreal ravine
#

u need to add the role 2 the member

supple storm
broken turtle
boreal ravine
#

then remove the .mute line

broken turtle
#

what should i replace it with then

boreal ravine
#

u already gave the role

#

and sent the mute message

pure reef
#

mute cmds r easy

pure reef
#

i'm gonna try nd make a snipe cmd

maiden fable
pure reef
#

me too 😭😭😭

maiden fable
unkempt canyonBOT
maiden fable
#

!d discord.Message.guild

unkempt canyonBOT
maiden fable
#

!d discord.Guild.owner

unkempt canyonBOT
maiden fable
#

(:

maiden fable
#

Do u have intents?

supple storm
broken turtle
#
@bot.command()
@commands.has_permissions(manage_roles = True)
async def mute(ctx, user : discord.Member,*,reason= "No reason provided idot", duration = 0, unit = None):
    roleobject = discord.utils.get(ctx.message.guild.roles, id=870577969477857289)
    await user.add_roles(roleobject)
    if unit == "s":
        wait = 1 * duration
        time.sleep(wait)
    elif unit == "m":
        wait = 60 * duration
        time.sleep(wait)
    await user.send("You have been muted in **Aurora  | Social • Icons • Anime** because:"+reason)
    await ctx.send(f":white_check_mark: {user} was muted for {duration}") 

lol ok i got no errors

maiden fable
#

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

maiden fable
#

Member intent, that's what u need

maiden fable
#

Indent lol

broken turtle
#

im confusaed

boreal ravine
#

aaa

maiden fable
#

Well I have to go. I am sure kayle will tell u the problem (:

boreal ravine
#

indents

broken turtle
#

i checxkt he indents

boreal ravine
unkempt canyonBOT
boreal ravine
#

@broken turtle wait

#

why is the duration 0

supple storm
#
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\luffy\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\luffy\Desktop\All Things\Code File\Python\Discord.py\MineHardcore.py", line 169, in on_message
    if Member.mention in message.content:
AttributeError: 'NoneType' object has no attribute 'mention'
#

@maiden fable noice

boreal ravine
#

1*0 is 0 @broken turtle

slate swan
#

because 60m is taken as the reason and duration not specified so its 0

boreal ravine
#

o

maiden fable
supple storm
#

yes

maiden fable
visual island
supple storm
maiden fable
visual island
maiden fable
reef trail
#

is there a way i can actively adjust to ratelimits to be able to add / delete something as fast as possible without triggering the ratelimit?

visual island
maiden fable
#

This was the reason the ratelimits ain't static

visual island
reef trail
#

you cant bulk reset nicknames iirc

maiden fable
silver wolf
maiden fable
visual island
reef trail
#

okay well is there a way i can actively adjust a asyncio.sleep()? Like, i dont just want preset values, i want it to be dynamic to the already dynamic dpy ratelimits

maiden fable
visual island
visual island
maiden fable
reef trail
#

can i use random integers for a sleep() then?

visual island
reef trail
#

so the time that sleeps is "random"

maiden fable
pallid meadow
maiden fable
unkempt canyonBOT
#

random.randint(a, b)```
Return a random integer *N* such that `a <= N <= b`. Alias for `randrange(a, b+1)`.
pallid meadow
#

just make sure you use asyncio sleep

maiden fable
#

Yea

reef trail
#
asyncio.sleep(random.randint(1, 0.05))```
pallid meadow
#

and not regular time.sleep so you don't run into blocking

maiden fable
#

time.sleep is blocking and can stop great whole bot

pliant gulch
#

Send a raw request to the discord API, you can check the x-ratelimit-... keys in the response headers

maiden fable
pliant gulch
#

Use that to decide how long to wait for

reef trail
visual island
maiden fable
reef trail
#

hm, okay

#

Thanks

maiden fable
slate swan
pure reef
#

is there on_mention events ?

shell wing
#
@client.command()
async def apply(ctx, user:discord.Member=None):
  if ctx.author.id is 781583513815220235:
    await ctx.send("Currently you are blacklisted from using this command")
  else:
    user = user or ctx.author
    role = ctx.guild.get_role(822001928593997875)
    await user.add_roles(role)
    await ctx.send(f"{ctx.author.mention} is a Official now !!!")
``` i cant check the command right now... the original one works (the one without `if` and `else`) i have added these else and if so would it work ??
pure reef
#

so when someone mentions my bot i can send something

maiden fable
slate swan
maiden fable
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/stable/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.
slate swan
pure reef
#

where am i supposed to put that

slate swan
slate swan
#

you put a timeout error

#

it probably raised that

slate swan
#

send the bot

slate swan
maiden fable
visual island
#
class MyData:
    def __init__(self, _id: int):
        self.joined_at: datetime.datetime = self.select("joined_at")

so currently, self.joined_at selects a data in the db, but it wont be updating everytime I updated the db, how do i make so self.joined_at also updating everytime I update the db? I saw dpy uses _handle_something and flatten_handlers class decorator (but that would be quite long and i kinda dont like it), should I use that too?

slate swan
#

like for ?ban you can do @bot_mention ban

slate swan
slate swan
#
  pos = ["s","m","h","d"]

  time_dict = {"s" : 1, "m" : 60, "h" : 3600, "d": 3600*24}

  unit = time[-1]

  if unit not in pos:
    return -1
  try:
    val = int(time[:-1])
  except:
    return -2

  return val * time_dict[unit]

@client.command()
@commands.has_permissions()
async def giveaway(ctx):
  await ctx.send("Let's start with this giveaway! Answer these questions within 15 seconds!")

  questions = ["Which channel should it be hosted in?", "What should be the duration of the giveaway? (s|m|h|d)", "What is the prize of the giveaway?"]

  answers = []

  def check(m):
    return m.author == ctx.author and m.channel == ctx.channel

  for i in questions:
    await ctx.send(i)

    try:
      msg = await client.wait_for('messsage', timeout=15.0, check=check)
    except asyncio.TimeoutError:
      await ctx.send('You didn\'t answer in time, please be quicker next time!')
      return
    else: 
      answers.append(msg.content)

  try:
    c_id = int(answers[0][2:-1])
  except:
    await ctx.send(f"You didn't mention a channel properly. Do it like this {ctx.channel.mention} next time.")
    return

  channel = client.get_channel(c_id)

  time = convert(answers[1])
  if time == -1:
    await ctx.send(f"You didn't answer with a proper unit. Use (s|m|h|d) next time!")
    return
  elif time == -2:
    await ctx.send(f"The time just be an integer. Please enter an integer next time.")
    return
  
  prize = answers[2]

  await ctx.send(f"The giveaway will be in {channel.mention} and will last {answers[1]} seconds!")

  embed = discord.embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)

  embed.add_field(name = "Hosted by:", value = ctx.author.mention)

  embed.set_footer(text = f"Ends {answers[1]} from now!")

  my_msg = await channel.send(embed = embed)

  await my_msg.add_reaction("🎉")

  await asyncio.sleep(time)

  new_msg = await channel.fetch_message(my_msg.id)

  users = await new_msg.reactions[0].users().flatten()
  users.pop(users.index(client.user))

  winner = random.choice(users)

  await channel.send(f"Congratulations! {winner.mention} won the prize: {prize}!")


@client.command()
@commands.has_permissions(kick_members=True)
async def reroll(ctx, channel : discord.TextChannel, id_ : int):
  try:
    new_msg = await channel.fetch_message(id_)
  except:
    await ctx.send("The ID that was entered was incorrect, make sure you have entered the correct giveaway message ID.")
  users = await new_msg.reactions[0].users().flatten()
  users.pop(users.index(client.user))

  winner = random.choice(users)

  await channel.send(f"Congratulations the new winner is: {winner.mention} for the giveaway rerolled!")```
#

nah fam

slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.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.

slate swan
#

don't just pastes so much code here

maiden fable
slate swan
#

someone teach me python lol

unkempt canyonBOT
#

discord/message.py lines 794 to 795

def _handle_pinned(self, value: bool) -> None:
    self.pinned = value```
maiden fable
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

maiden fable
slate swan
slate swan
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.pydis.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.

slate swan
#

please

patent lark
#

ok

maiden fable
#

Hi snow. Only u can help Kylee

visual island
boreal ravine
maiden fable
patent lark
slate swan
# boreal ravine ru copying code

@client.command()
@commands.has_permissions()
async def giveaway(ctx):
await ctx.send("Let's start with this giveaway! Answer these questions within 15 seconds!")

questions = ["Which channel should it be hosted in?", "What should be the duration of the giveaway? (s|m|h|d)", "What is the prize of the giveaway?"]

answers = []

def check(m):
return m.author == ctx.author and m.channel == ctx.channel

for i in questions:
await ctx.send(i)

try:
  msg = await client.wait_for('messsage', timeout=15.0, check=check)
except asyncio.TimeoutError:
  await ctx.send('You didn\'t answer in time, please be quicker next time!')
  return
else: 
  answers.append(msg.content)

try:
c_id = int(answers[0][2:-1])
except:
await ctx.send(f"You didn't mention a channel properly. Do it like this {ctx.channel.mention} next time.")
return

channel = client.get_channel(c_id)

time = convert(answers[1])
if time == -1:
await ctx.send(f"You didn't answer with a proper unit. Use (s|m|h|d) next time!")
return
elif time == -2:
await ctx.send(f"The time just be an integer. Please enter an integer next time.")
return

prize = answers[2]

await ctx.send(f"The giveaway will be in {channel.mention} and will last {answers[1]} seconds!")no yes from youtube

#

bruh

boreal ravine
#

what no i've seen this code before

patent lark
#

is it that hard

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.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.

slate swan
#

how many times do i tell you..

#

youtube

boreal ravine
#

it's @fading mica's code

slate swan
maiden fable
#

😂🤣

slate swan
#

hmm

patent lark
#

copying isnt learning

slate swan
#

you'll learn from docs not YT

maiden fable
patent lark
#

copying and going "Okay this should work" isnt learning.

slate swan
#

stop copying from vids, you don't really learn unless you actually understand the code.

maiden fable
#

Indeed

visual island
maiden fable
vagrant brook
#

👀

#

Can I see your bot

slate swan
#

ohk

patent lark
visual island
vagrant brook
#

I've been looking for AI bots

maiden fable
maiden fable
vagrant brook
#

Anything AI-related

patent lark
slate swan
maiden fable
#

The API isn't public @patent lark

patent lark
#

well the bot itself.

#

dumb dumb.

visual island
maiden fable
#

Indeed lol

slate swan
#

Can I see it too? 👀

maiden fable
visual island
maiden fable
slate swan
patent lark
#

!e py def foo(): print("Hunter make the API public") foo()

unkempt canyonBOT
#

@patent lark :white_check_mark: Your eval job has completed with return code 0.

Hunter make the API public
maiden fable
slate swan
#

Lmao

slate swan
obtuse egret
#
@client.command(aliases=['repeat', 'rep'])
async def loop(self, ctx: commands.Context):
    if not ctx.voice_state.is_playing:
        return await ctx.send('Nothing being played at the moment.')

        ctx.voice_state.loop = not ctx.voice_state.loop
        await ctx.send("*This track will now repeat*")

I've got ctx in the argument, but I'm still presented with the error : ctx is a required argument that is missing

maiden fable
slate swan
slate swan
#

i've told you to !paste your code you haven't done that

boreal ravine
#

remove self

slate swan
#

self is for cogs, you don't seem to be using em

boreal ravine
#

yes

slate swan
slate swan
#

!pastes

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

slate swan
#

bruh?

#

you want me to give you code? no

#

and im not interested thanks

spring flax
mild geode
#

If I want to see the nick name is it {user.display.name} orrrr {user.display_name} or am I wrong wrong

compact field
#

guys i wrote while True loop in on_ready. and after minutes bot got off .what is wrong?

slate swan
#

member*

#

!d discord.Member.display_name

unkempt canyonBOT
#

display_name```
Returns the user’s display name.

For regular users this is just their username, but if they have a guild specific nickname then that is returned instead.
boreal ravine
#

ugh

slate swan
boreal ravine
#

sorry lmfao

mild geode
unkempt canyonBOT
slate swan
#

use displayname it is better

boreal ravine
#

yes

mild geode
boreal ravine
mild geode
#

Yes yes got that part, thank you @boreal ravine

boreal ravine
#

👍

slate swan
slate swan
# slate swan pls yelp

i don't know how many times ive told you, not sure if you understand, can you please !paste your code!!??

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

slate swan
#

!p def convert(time):
pos = ["s","m","h","d"]

time_dict = {"s" : 1, "m" : 60, "h" : 3600, "d": 3600*24}

unit = time[-1]

if unit not in pos:
return -1
try:
val = int(time[:-1])
except:
return -2

return val * time_dict[unit]

@client.command()
@commands.has_permissions()
async def giveaway(ctx):
await ctx.send("Let's start with this giveaway! Answer these questions within 15 seconds!")

questions = ["Which channel should it be hosted in?", "What should be the duration of the giveaway? (s|m|h|d)", "What is the prize of the giveaway?"]

answers = []

def check(m):
return m.author == ctx.author and m.channel == ctx.channel

for i in questions:
await ctx.send(i)

try:
  msg = await client.wait_for('messsage', timeout=15.0, check=check)
except asyncio.TimeoutError:
  await ctx.send('You didn\'t answer in time, please be quicker next time!')
  return
else: 
  answers.append(message.content)

try:
c_id = int(answers[0][2:-1])
except:
await ctx.send(f"You didn't mention a channel properly. Do it like this {ctx.channel.mention} next time.")
return

channel = client.get_channel(c_id)

time = convert(answers[1])
if time == -1:
await ctx.send(f"You didn't answer with a proper unit. Use (s|m|h|d) next time!")
return
elif time == -2:
await ctx.send(f"The time just be an integer. Please enter an integer next time.")
return

prize = answers[2]

await ctx.send(f"The giveaway will be in {channel.mention} and will last {answers[1]} seconds!")

embed = discord.embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)

embed.add_field(name = "Hosted by:", value = ctx.author.mention)

embed.set_footer(text = f"Ends {answers[1]} from now!")

my_msg = await channel.send(embed = embed)

await my_msg.add_reaction("🎉")

await asyncio.sleep(time)

new_msg = await channel.fetch_message(my_msg.id)

users = await new_msg.reactions[0].users().flatten()
users.pop(users.index(client.user))

winner = random.choice(users)

await channel.send(f"Congratulations! {winner.mention} won the prize: {prize}!")

@client.command()
@commands.has_permissions(kick_members=True)
async def reroll(ctx, channel : discord.TextChannel, id_ : int):
try:
new_msg = await channel.fetch_message(id_)
except:
await ctx.send("The ID that was entered was incorrect, make sure you have entered the correct giveaway message ID.")
users = await new_msg.reactions[0].users().flatten()
users.pop(users.index(client.user))

winner = random.choice(users)

await channel.send(f"Congratulations the new winner is: {winner.mention} for the giveaway rerolled!")

unkempt canyonBOT
#
Bad argument

Converting to "int" failed for parameter "pep_number".

#
Command Help

!pep <pep_number>
Can also use: get_pep, p

Fetches information about a PEP and sends it to the channel.

compact field
slate swan
#

!paste def convert(time):
pos = ["s","m","h","d"]

time_dict = {"s" : 1, "m" : 60, "h" : 3600, "d": 3600*24}

unit = time[-1]

if unit not in pos:
return -1
try:
val = int(time[:-1])
except:
return -2

return val * time_dict[unit]

@client.command()
@commands.has_permissions()
async def giveaway(ctx):
await ctx.send("Let's start with this giveaway! Answer these questions within 15 seconds!")

questions = ["Which channel should it be hosted in?", "What should be the duration of the giveaway? (s|m|h|d)", "What is the prize of the giveaway?"]

answers = []

def check(m):
return m.author == ctx.author and m.channel == ctx.channel

for i in questions:
await ctx.send(i)

try:
  msg = await client.wait_for('messsage', timeout=15.0, check=check)
except asyncio.TimeoutError:
  await ctx.send('You didn\'t answer in time, please be quicker next time!')
  return
else: 
  answers.append(message.content)

try:
c_id = int(answers[0][2:-1])
except:
await ctx.send(f"You didn't mention a channel properly. Do it like this {ctx.channel.mention} next time.")
return

channel = client.get_channel(c_id)

time = convert(answers[1])
if time == -1:
await ctx.send(f"You didn't answer with a proper unit. Use (s|m|h|d) next time!")
return
elif time == -2:
await ctx.send(f"The time just be an integer. Please enter an integer next time.")
return

prize = answers[2]

await ctx.send(f"The giveaway will be in {channel.mention} and will last {answers[1]} seconds!")

embed = discord.embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)

embed.add_field(name = "Hosted by:", value = ctx.author.mention)

embed.set_footer(text = f"Ends {answers[1]} from now!")

my_msg = await channel.send(embed = embed)

await my_msg.add_reaction("🎉")

await asyncio.sleep(time)

new_msg = await channel.fetch_message(my_msg.id)

users = await new_msg.reactions[0].users().flatten()
users.pop(users.index(client.user))

winner = random.choice(users)

await channel.send(f"Congratulations! {winner.mention} won the prize: {prize}!")

@client.command()
@commands.has_permissions(kick_members=True)
async def reroll(ctx, channel : discord.TextChannel, id_ : int):
try:
new_msg = await channel.fetch_message(id_)
except:
await ctx.send("The ID that was entered was incorrect, make sure you have entered the correct giveaway message ID.")
users = await new_msg.reactions[0].users().flatten()
users.pop(users.index(client.user))

winner = random.choice(users)

await channel.send(f"Congratulations the new winner is: {winner.mention} for the giveaway rerolled!")

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

compact field
#

just in on_ready

boreal ravine
compact field
boreal ravine
compact field
#

i want to creat while

boreal ravine
#

o

compact field
#

infinity loop

#

always

slate swan
boreal ravine
#

@slate swan what error

slate swan
#

yeah, what's the issue

compact field
#

please some body help me :(

slate swan
slate swan
slate swan
slate swan
#

please

compact field
slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.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.

compact field
#

ok wait

slate swan
#

firstly

#

what's @commands.has_permissions()

#

@slate swan

#

Delete it now!!!!

#

You put your token

slate swan
#

read this, be careful

slate swan
compact field
slate swan
#

!d discord.ext.commands.has_permissions

unkempt canyonBOT
#

discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.

Note that this check operates on the current channel permissions, not the guild wide permissions.

The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions").

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

you need to put a permission

slate swan
#

=true

#

okay..

#

see

pale turtle
#

There is a typo

slate swan
slate swan
slate swan
pale turtle
#

It should be administrator

spring flax
slate swan
#

check how you wrote administrator

slate swan
compact field
slate swan
slate swan
#

I don't want server links

maiden fable
slate swan
#

its name is testing bot

slate swan
slate swan
slate swan
#

sorry

#

have you read discord ToS? don't just dm links without permission

maiden fable
maiden fable
#

starts DMing everyone my bot link

compact field
slate swan
slate swan
#

sorry i forgot to ask

#

okay. anyways

#

what's the error with the code

boreal ravine
slate swan
#

you haven't said it yet

#

and want help

#

don't ask me to join your server, just say what's wrong

slate swan
#

no error

#

you also put your db info

#

might wanna cut that out too

#

deleted

compact field
slate swan
slate swan
#

does it not say anything

#

await ctx.send("Let's start with this giveaway! Answer these questions within 15 seconds!")

#

not this?

slate swan
slate swan
slate swan
#

do you even know what it means

#

bru sorry

#

answer my question please

slate swan
#

do you?

slate swan
#

if we wont answer in 15 seconds the bot will not take in next command

#

okay last question

slate swan
#

did you do the coding while he was explaining or did you copy from github

#

or something else

slate swan
maiden fable
#

@slate swan yr doggo cutie

slate swan
slate swan
slate swan
compact field
slate swan
#

well i'm sorry i have to go for work to do..

#

you'll have to wait for someone else to help you sorry

#

ohk

slate swan
maiden fable
compact field
maiden fable
#

Not a code problem
-> Discord Diconnected Your Bot
-> The Internet Went
-> The Machine Shut Down

compact field
slate swan
#

connecting it to discord requires an internet connection

#

if you don't have internet it won't connect

#

what

compact field
slate swan
slate swan
slate swan
#

and collect all the information

#

if you don't know how to do it put duration prize etc as positional command args

#

and use speechmarks for more than a word

#

don't use x, *, y

slate swan
honest ermine
#

Hi, a newbie question: How can I add a method as a command? I have a class that subclass discord.ext.commands.Bot

elder python
#

whats the decorator to chedck for perms in a cog

slate swan
slate swan
#

bois I fixed my discord bot bug. It was literally a matter of me forgetting that the arg "check" exists in wait_for() ;-;

slate swan
slate swan
#

let me see your import statement(s)

slate swan
#

ok, problem

slate swan
#

you see, when importing a module like that:

#

from datetime import datetime, time

slate swan
#

the module name is the same as one of its descendants I'm assuming?

maiden fable
#

Yes

slate swan
#

uh

#

so i think the program might be confusing the two

#

🎉

#

There's a way to insure that but I forgot how

slate swan
maiden fable
#

!d datetime.timedelta

unkempt canyonBOT
#

class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to `0`. Arguments may be integers or floats, and may be positive or negative.

Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
maiden fable
#

Do

#

from datetime import timedelta

#

(:

slate swan
#

Oh yeah that works too

#

Bruh I'm dumb smh

#

No wonder it took me 3 days to fix this damn bug

slate swan
#

Yeah that should work

slate swan
slate swan
#

wym

slate swan
slate swan
slate swan
#

anyone here using relplit?

stark bobcat
#

me

slate swan
#

i am getting this error, when i try to open my repl site, (i am trying to use uptimer bot)
Hmmmm.... We Couldn't Reach Your Repl Make sure your repl has a port open and is ready to receive HTTP traffic.

lofty mulch
#

@slate swan Beluga?

slate swan
#

uh no

lofty mulch
#

ok

#

So, anyway

slate swan
#

Hi

lofty mulch
#

I'm trying to make my bot recept messages and send them to a specific channel

#

that can be modified through a command

#

How can I make the bot only take the channel ID as an argument?

lofty mulch
#

thx

slate swan
slate swan
lofty mulch
#

FFS

#

now it won't import anything, great

slate swan
lofty mulch
#

It was working fine just a few hours ago, I didn't even touch the file

blazing beacon
#

Replit or?

lyric moat
#

how can i track daily messages?

lofty mulch
#

nop, vscode

#

I'm not even surprised at this point because God forbidden I have a smooth experience while coding

slate swan
#

!d discord.on_message

unkempt canyonBOT
#

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

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/stable/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/stable/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
slate swan
#

you mean on message events?

lofty mulch
#
    client.load.extension(f'CogHolder.{filename[:-3]}')
AttributeError: 'Bot' object has no attribute 'load'```
lyric moat
lofty mulch
#

Ooooh, I see what's happening

lofty mulch
#

Or not

slate swan
lofty mulch
#

Well, it gave the same error

slate swan
slate swan
maiden fable
lofty mulch
#

Oooo

#

Oops

slate swan
#

load_extension

lofty mulch
#

Well, it gave a different error

#

It's a start, atleast

slate swan
#

see

#

okay?

#

pass in the arguement then

#

you made it positional

slate swan
#

howpls just tell me

#

i did the whole thing by me

slate swan
#

tell me how

#

what should i change

#

anyone

slate swan
brazen raft
#

lmao

slate swan
wispy sequoia
#

help

#

status=discord.Status.dnd

#

is it idle

crisp pine
#

does anyone know how to steal emojis command?

wispy sequoia
#

steal emojis?

maiden fable
#

@unkempt canyon

#

Is online ok

slate swan
slate swan
wispy sequoia
#

I want it on dnd

slate swan
slate swan
wispy sequoia
slate swan
#

remove idle and put dnd

wispy sequoia
slate swan
#

or else remove status

#

1 sec add it again and then put dnd

wispy sequoia
# slate swan send me this command i need this
@client.event
async def on_ready():
    await client.change_presence(activity=discord.Activity(name="in the space | Prefix is #", type=discord.ActivityType.playing), status=discord.Status.idle)
    print("Ready!")```
slate swan
#

I have this code```py
await c.execute(f"SELECT amount FROM warn WHERE userid={member.id} ")
user = await c.fetchone()
if user is None:
await c.execute(f"INSERT INTO warn VALUES ({member.id}, 0)")
await ctx.send("User added to db")
else:
await ctx.send(f"User exist, and amount is: {user}")

and get this error ```py
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 994, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 894, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 176, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: unrecognized token: "877835890574118932 "
grim mango
#

how can i set the Listening to status?

#

and Watching status?

#

and Competing in status?

maiden fable
#

!d discord.ActivityType

unkempt canyonBOT
#

class discord.ActivityType```
Specifies the type of [`Activity`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Activity "discord.Activity"). This is used to check how to interpret the activity itself.
maiden fable
#

!d discord.Activity

unkempt canyonBOT
#

class discord.Activity(**kwargs)```
Represents an activity in Discord.

This could be an activity such as streaming, playing, listening or watching.

For memory optimisation purposes, some activities are offered in slimmed down versions:

• [`Game`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Game "discord.Game")

• [`Streaming`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Streaming "discord.Streaming")
grim mango
#

thx @maiden fable

split kraken
#
import discord
import os
import datetime
from dotenv import load_dotenv
from discord.ext import commands

load_dotenv()

#Global Variables
intents = discord.Intents()
intents.members = True
bot = commands.Bot(command_prefix=['n','N','n!','N!'], intents=intents)
bot.remove_command("help")

#Events
@bot.event
async def on_ready():
    print("Logged in!")
    await bot.change_presence(activity=discord.Game(name="nhelp"))

#Basic Commands
@bot.command()
async def help(ctx):
    em = discord.Embed(color=discord.Color.red())
    em.set_author(name="Ningo Command Section", icon_url=bot.user.avatar_url)
    em.add_field(name="Basic Commands",value="help, serverinfo, si, memberinfo, mi, avatar, av, invite, inv, ping")
    await ctx.send(embed=em)

@bot.command(aliases=['av'])
async def avatar(ctx, member:discord.Member=None):
    if member is None:
        member = ctx.author
    em = discord.Embed(title=f"{member}'s avatar", color=discord.Color.red())
    em.set_image(url=member.avatar_url)
    await ctx.send(embed=em)

@bot.command(aliases=['mi'])
async def memberinfo(ctx, member:discord.Member=None):
    if member is None:
        member = ctx.author
    accCreate = member.created_at.strftime("%d %b %y %H:%M:%S UTC")
    joinDate = member.joined_at.strftime("%d %b %y %H:%M:%S UTC")
    x = datetime.datetime.utcnow()
    accAge = x - member.created_at
    joinServerAge = x - member.joined_at


    embed = discord.Embed(color=discord.Color.red(), title=f"{member.name}#{member.discriminator} (@{member.display_name})")
    embed.add_field(name="ID", value=f"{member.id}")
    if member.name != member.display_name:
        embed.add_field(name="Actual membername", value=f"{member.name}")
    embed.add_field(name="Avatar", value=f"[Link]({ctx.author.avatar_url})")
    embed.add_field(name="Created Account On", value=f"{accCreate}")
    embed.add_field(name="Created Account", value=f"{accAge} ago")
    embed.add_field(name="Joined Server On", value=f"{joinDate}")
    embed.add_field(name="Joined Server", value=f"{joinServerAge} ago")
    embed.add_field(name="Member's Top Role", value={member.top_role.name})
    embed.set_thumbnail(url=member.avatar_url)
        
    await ctx.send(embed=embed)

@bot.command()
async def ping(ctx):
    latency = round((bot.latency)*1000)
    await ctx.send(f":ping_pong: My latency is {latency}ms")

@bot.command(aliases=['inv'])
async def invite(ctx):
    await ctx.send("https://discord.com/api/oauth2/authorize?client_id=885040999066386452&permissions=8&scope=bot")

@bot.command(aliases=['si'])
async def serverinfo(ctx):
    em = discord.Embed(description=f"**Owner:** :crown:{ctx.guild.owner}\n**Members:** :busts_in_silhouette:{ctx.guild.member_count}\n**Channels:** :hash:{len(ctx.guild.text_channels)} :loud_sound:{len(ctx.guild.voice_channels)}\n**Region:** :flag_white:{ctx.guild.region}\n**ID:** :id:{ctx.guild.id}", color=discord.Color.red())
    em.set_author(name=ctx.guild.name, icon_url=ctx.guild.icon_url)
    await ctx.send(embed=em)


bot.run(os.getenv("DISCORD_TOKEN"))

The commands are not being executed

#

help someone pls

slate swan
velvet crest
split kraken
velvet crest
spring flax
split kraken
spring flax
#

no error?

slate swan
spring flax
#

do you know what that means?

slate swan
#

tell me

#

my net is lagging

slate swan
split kraken
slate swan
#

hello

velvet crest
# slate swan

answers is an empty list and ur trying to index it thats why ur getting that error

#

there's nothing in it.

slate swan
lofty mulch
#
discord.ext.commands.errors.ExtensionFailed: Extension 'Cogs.MainCog' raised an error: TypeError: module() takes at most 2 arguments (3 given)```
#

Any idea on what this error might be?

velvet crest
velvet crest
#

what are ur imports in that cog ?

lofty mulch
#

import os
import discord
from discord.ext import commands
from discord.ext.commands.errors import ExtensionNotFound
from dotenv import load_dotenv

#

Apparently it autoimported commands.errors??

slate swan
slate swan
#

What is MainCog

velvet crest
lofty mulch
boreal ravine
slate swan
#

And your setup() method? did you ```py
def setup(bot):
bot.add_cog(Cogs.MainCog(bot))

lofty mulch
#

I did, although I used client.add instead of bot.add

#

I'll give it a try with bot.add

slate swan
#

Nah that's fine

waxen granite
#

How can a disable/enable a cog?

#

For a specific guild

slate swan
slate swan
lofty mulch
#

Still giving the same error

velvet crest
# slate swan help

See, in that cmd ur provided an empty list then appended it based on the data provided, then indexed the prize, in the reroll cmd u did not do the same, to get the prize u must define it or access it thru the embed which would be confusing for u, so an alternative is to use db and store the info there too... but then u will have to keep removing the data once the giveaway has ended completed so just remove the prize part.

lofty mulch
#
    if filename.endswith('.py'):
        client.load_extension(f'Cogs.{filename[:-3]}') # This One
        print ('{} has been loaded!'.format('MainCog'))```
slate swan
# slate swan help

The prize is not an instance variable and localised to the method only, make it instance var or do something else to make it available in other func

lofty mulch
#

specific*

slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.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.

lofty mulch
#
async def load(ctx, extension):
    client.load_extension(f'Cogs.{extension}')

@client.command()
async def unload(ctx, extension):
    client.unload_extension(f'Cogs.{extension}')

for filename in os.listdir('./Cogs'):
    if filename.endswith('.py'):
        client.load_extension(f'Cogs.{filename[:-3]}')
        print ('{} has been loaded!'.format('MainCog'))
#

This is the entirety of the init process for the cogs

crisp pine
lofty mulch
#

I tried messing around with the names to see if it would load if I declared the name, but it still didn't work

velvet crest
velvet crest
lofty mulch
#

just Cogs

velvet crest
#

ist Cogs or cogs

lofty mulch
#

Cogs with capital C

velvet crest
slate swan
lofty mulch
#

oooo

velvet crest
#

Wdym by command ?

lofty mulch
#

That's the whole cog

slate swan
#

And not commands.bot

#

It's mostly wrong

lofty mulch
#

ooh

stark bobcat
#

Hoi

waxen granite
#

get the role first, then if role not in member.roles: then await ctx.send("you cannot used the cmd as you dont have the role for it")

lofty mulch
#

Lemme try

slate swan
lofty mulch
#

And of course, it's still giving the same error

#

You know what, might just call it a night and get some rest

waxen granite
#
role = discord.utils.get(ctx.guild.roles, name = "whatever")
if role not in ctx.author.roles:
    await ctx.send()
velvet crest
#

there are 2 ways either by providing
@commands.has_role(roleid)
decorator
or get the role inside the command and do
role = discord.utils.get(ctx.guild.roles, id = roleid)
if not role in ctx.author.roles:
return await ctx.send("You need the {role.mention}, to use this command")

lofty mulch
#

Actually

#

It worked after I deleted the line

slate swan
velvet crest
#

Use database for it.

slate swan
#

Just have a look at the shared link to see how to make one

lofty mulch
#

Thing is, it apparently was loading twice

velvet crest
lofty mulch
#

Well, lesson learned

velvet crest
#

and also yes its same, but it wont run unless u do !load test

waxen granite
lofty mulch
#

I should start paying attention to what I write

quaint chasm
#

can any one help to create a api with ML model

#

for chatbot

chilly fossil
#

hola

slate swan
#

Try it and see

#

I'm not a debugger or docs blobpain

#

And please don't ping anyone randomly

maiden fable
#

Lmao

#

BTW Akshu, u got the answer?

slate swan
#

No notlikeblob

velvet crest
slate swan
#

is it possible to make embed auto response?

maiden fable
#

time to ping Kylee and demand an explanation

slate swan
#

Someone tell me how to typehint a snowflake which is a str and I need to name it ID blobpain

wispy sequoia
#

I need to know discord permessions

maiden fable
unkempt canyonBOT
#

class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.

The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.

Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.update "discord.Permissions.update").
wispy sequoia
wispy sequoia
maiden fable
slate swan
#

oh like when i said hello it's reply with "hello world" but in embed

slate swan
wispy sequoia
#

sure

velvet crest
slate swan
#

how though i try it and i mess it up

maiden fable
unkempt canyonBOT
#

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

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/stable/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/stable/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
maiden fable
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(**kwargs)```
Represents a Discord embed.

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

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/stable/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.
frigid badge
#

Hey can someone help me , my bot is doing executing commands twice due to these lines of code

async def initialise(): await client.wait_until_ready() client.db = await aiosqlite.connect("expData.db") await client.db.execute("CREATE TABLE IF NOT EXISTS guildData (guild_id int, user_id int , exp int, PRIMARY KEY (guild_id, user_id))")

can someone tell me whats wrong ?

maiden fable
#

!d discord.Message.channel

unkempt canyonBOT
maiden fable
#

!d discord.TextChannel.send

unkempt canyonBOT
#

await send(content=None, *, tts=False, embed=None, file=None, files=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=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/stable/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/stable/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed "discord.Embed") and it must be a rich embed type.
slate swan
#

Dude, just name the methods instead of spamming python rooMonkaS

maiden fable
slate swan
#

Python has an automute

maiden fable
wispy sequoia