#discord-bots

1 messages · Page 990 of 1

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

slate swan
#

delete that msg

river swift
#

How could I make a discord bot with python from scratch?

slate swan
#

you could use a wait_for

river swift
#

:,v

slate swan
#

english only

slate swan
slate swan
chilly igloo
brave forge
#

@slate swan that is , the same way to process as the buttons ?

river swift
brave forge
slate swan
#

ok np

brave forge
#

I just wanted to send. How many Russians I started meeting but accidentally sent this

slate swan
#

@brave forge you're using discord.py or what library?

slate swan
#

lol

brave forge
slate swan
brave forge
#

@slate swanfor buttons I remember using "from discord_components import Discord Components, Button, ButtonStyle" but it didn't work

slate swan
#

you cant name a function like you did

#

пред can't be used in python for naming a class/variable/function

brave forge
chilly igloo
slate swan
#

use @bot.command(name="пред")

chilly igloo
slate swan
#

guess what i find

slate swan
slate swan
main sonnet
slate swan
#

sure

#

and this is my cog itself

''' how I load it '''
[bot.load_extension(f"./cogs/{file[:-3]}") for file in os.listdir("./cogs") if file.endswith(".py")]
#

disnake cool

brave forge
slate swan
brave forge
slate swan
slate swan
#

got a new idea for cmd

#

!!

slate swan
slate swan
#

same error?

brave forge
#

how to do that when you click the reaction. In the first case, the command continued, and in the second it stopped or displayed a message like no !?

slate swan
#

oh wait, thats not how you load an extension

slate swan
#

it worked twice before

slate swan
#

not in this bot*

#

I recently reset my Token, and now the data in MySQL won’t update? does the token have anything to do with it?

slate swan
#

sheesh

#

..

brave forge
#

@slate swan how to do that when you click the reaction. In the first case, the command continued, and in the second it stopped or displayed a message like no !?

slate swan
#

hmm alrighty

slate swan
#

cool

brave forge
slate swan
#

Like I'm doing this as of now, which obviously wont work

def check_limit(self):
        async def predicate(ctx):
            user = await self.bot.db.read(query={"key": ctx.author.id})
            if len(user['notes']) >= 5:
                raise MaximumValuesReached()
            return True
        return commands.check(predicate)
#

oh no its easier

slate swan
#

ah

#

!d discord.ext.commands.Cog.cog_check

unkempt canyonBOT
#

cog_check(ctx)```
A special method that registers as a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") for every command and subcommand in this cog.

This function **can** be a coroutine and must take a sole parameter, `ctx`, to represent the [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context").
slate swan
#

yep

#

thanks a lot uwu sarthak

#

Seeing as it has nothing to do with my token it must be my code. So, Ive made it so when a user renames a ticket to {user}-done my database updates their count by 1, however, i recently reset my bots token and now that doesnt work. But, other parts of the database works, like adding users to the database and so forth. Here's my code:

users = sorted(users.items(), key=lambda x: x[1], reverse=True)
for i in users:
  mycursor.execute(f"SELECT * FROM logs_info")
  for i2 in mycursor:
    if str(i2[1]) == str(i[0]):
      NewCount = int(i2[2])+int(i[1])
  mycursor.execute(f"UPDATE logs_info set count = '{NewCount}' WHERE username = '{i[0]}'")
  db.commit()
mycursor.close()
db.close()

I get no errors..

boreal ravine
brave forge
#

@boreal ravine how to do that when you click the reaction. In the first case, the command continued, and in the second it stopped or displayed a message like no !?

opal cosmos
#

how to make cooldown message without using global error handlers, bcs im kinda not liking it eating my errors

slate swan
boreal ravine
spring flax
#

this would be better (needs the traceback and sys module)```py
else:
print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
traceback.print_exception(type(error), error, error.traceback, file=sys.stderr)

boreal ravine
sacred oyster
#

how do i make a coinflip command?

sacred oyster
spring flax
#

you have to import

boreal ravine
vast gale
dull terrace
#

How tf are you supposed to test the patreon API if you can't pledge to your own campaign

boreal ravine
# boreal ravine yes..
import random

if random.choice(["heads, "tails"]) == "heads": #picks a random value
    ...
boreal ravine
sacred oyster
broken elk
#

What's your best suggestion for keeping a discord bot online? I work on a Chromebook.

boreal ravine
broken elk
boreal ravine
sacred oyster
#

ok

quaint epoch
#

@delicate trench over here

brave forge
quaint epoch
#

!pypi disnake

unkempt canyonBOT
broken elk
quaint epoch
#

this is an api wrapper, makes life a million times easier

#

you need a bot user to use it tho

boreal ravine
quaint epoch
boreal ravine
broken elk
brave forge
cold sonnet
#

self.bot.wait_for

#

self.bot is your bot instance

strong vector
#

hi can i put events in one class?

cold sonnet
#

you mean cogs? sure

#

@commands.Cog.listener()
instead of @bot.event

strong vector
#

thanks

strong vector
#

to have*

cold sonnet
#

it doesn't look easy but it actually is

#

make a class where you subclass commands.Cog

strong vector
#

ye. but i want to learn what is exaicly cog

cold sonnet
#

your init should look like this:

def __init__(self, bot):
    self.bot = bot
strong vector
#

k

cold sonnet
#

so like

#

you make a subclass of Cog

#

then you make a setup function for it

#

so when you use load_extension, discord.py calls that setup function for you

#

or you can call it yourself

strong vector
#

i use Grepper
i found this code

from discord.ext import commands

class Test_Cog(commands.Cog):
    def __init__(self, bot):
      self.bot = bot # defining bot as global var in class
      
    @commands.Cog.listener() # this is a decorator for events/listeners
    async def on_ready(self):
      print('Bot is ready!.')
      
    @commands.command() # this is for making a command
    async def ping(self, ctx):
        await ctx.send(f'Pong! {round(self.bot.latency * 1000)}')
        
def setup(bot): # a extension must have a setup function
cold sonnet
#

do you use 2.0?

vale wing
#

This looks fine except setup is empty

strong vector
cold sonnet
#

dpy2.0

vale wing
#

Well not perfect but conceptually it is valid

strong vector
cold sonnet
strong vector
#

omg

cold sonnet
#

self.bot.wait_for

#

😔

cold sonnet
#

pretty inappropiate command

strong vector
cold sonnet
#

print(discord.version)

strong vector
cold sonnet
#

lmao

#

update it

strong vector
#

yup

#

that what i am going to do

#

its so old right?

restive palm
#

I have a dumb question, I saw they had discord.js would it be better in the long run to start and stay in python or is discord.js a good start, I plan on working on creating my own version of Carl bot and have never tried to make a project this big before.

restive palm
#

I have made some basic bots before just using py but I just learned they had js so wasn’t sure if it was a good idea

strong vector
slate swan
restive palm
#

I have done only py so far so wasn’t sure if js would be anything interesting

strong vector
#

idk i want to help but i am not good advicer

strong vector
#

oh shit i forget its ifter

#

bye

restive palm
#

I’m just not sure what discord’s plan was for py and js, I was wondering which would be better in the long run

boreal ravine
boreal ravine
#

they are practically the same

#

both have all the new features

slate swan
#

you just make requests/ws connection to the api, doesnt matter what language you use

restive palm
#

Ok so just personal preference basically

boreal ravine
#

yes

#

but python is more easier

static lintel
#
    client.crypto_pages = [cryptoEmbed, cryptoEmbed2, cryptoEmbed3, cryptoEmbed4, cryptoEmbed5, cryptoEmbed6, cryptoEmbed7, cryptoEmbed8]
    current = 0
    async def button_callback(interaction):
        await interaction.response.edit_message(content=client.crypto_pages[current+1])
    msg = await ctx.send(embed=client.crypto_pages[current], view=view)```
slate swan
#

ite easier because of its syntax and keywords

boreal ravine
static lintel
#

i was trying to scroll through embed pages using buttons but for some reason the interaction.response.edit_message part doesn't seem to do anything rn. did i mess up smt?

strong vector
restive palm
#

Yeah I don’t know much on js so that’s why I was asking

slate swan
#

and most libs provide an inbuilt/external command handler(s)

boreal ravine
strong vector
boreal ravine
restive palm
#

Yeah I have always used py just wasn’t sure if it was anything different for js

#

But if it’s personal preference definitely sticking with py

brave forge
#

the last question is it retoric

craggy cloak
#

I made a slash command to test but it don't show when I use the slash?

#

@bot.slash_command() async def hello(ctx, name: str = None): name = name or ctx.author.name await ctx.respond(f"Hello {name}!")

brave forge
craggy cloak
strong vector
#

"You need to verify your e-mail in order to perform this action."

#

how do i verify my email?

cold sonnet
#

one thing's for sure

#

your label is a tuple

#

and you're checking if it's a string in the if statement

dire folio
#

say i have to store one or two variables (externally) how should i store them?

cold sonnet
#

!bot-var

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

hushed galleon
#

ban_members, plural

#

yw

brave forge
cold sonnet
#

label = '1'

#

but I'm no expert at your third party lib

hushed galleon
cold sonnet
#

one or two

brave forge
cold sonnet
#

ok

#

no matter what, a slash command will say interaction failed if no response comes

#

or an interaction

#

yes

#

make sure to put something at the end to see if your buttons even worked

#

out of all if statements so it surely returns something

#

also, language

keen talon
#

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

brave forge
#

@slate swan
and where did you find all the access rights of discord ??

cold sonnet
#

the what

slate swan
#

what is this guy talking about

silver magnet
#
async def question(message):
    redditsub = reddit.subreddit('AskReddit')
    num = random.randrange(1, 100)
    for post in redditsub.hot(limit=num):
        await message.channel.send(post.title)
        return```
this command is supposed to choose any random reddit post but it always chooses the same one. what's wrong?
cold sonnet
#

😔

slate swan
slate swan
cold sonnet
#

ikr

slate swan
#

Hi

cold sonnet
silver magnet
#

when i didnt put the return it just spammed

cold sonnet
#

I think all you wanna do is just

#

await message.send(random.choice(redditsub.hot(limit=100)))

#

which looks complicated but really isn't

#

and don't name a Context instance message next time

#

uh is it a list

#

redditsub.host()

silver magnet
#

i just want to choose a single post

silver magnet
main sonnet
tired hinge
#

no colon after def

dire folio
#

!yt-dl

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)
dire folio
#

@main sonnet ^

tired hinge
#

completely forgot about that lmao

#

is channel : discord.Channel a thing

#

like, i want the user to input a channel

patent plinth
#

is the discord bot written in python?

velvet compass
#

Our community bots are

#

!contribute - if you are interested in knowing more about them

unkempt canyonBOT
#

Contribute to Python Discord's Open Source Projects
Looking to contribute to Open Source Projects for the first time? Want to add a feature or fix a bug on the bots on this server? We have on-going projects that people can contribute to, even if you've never contributed to open source before!

Projects to Contribute to
Sir Lancebot - our fun, beginner-friendly bot
Python - our utility & moderation bot
Site - resources, guides, and more

Where to start

  1. Read our contribution guide
  2. Chat with us in #dev-contrib if you're ready to jump in or have any questions
  3. Open an issue or ask to be assigned to an issue to work on
patent plinth
#

thanks

gray nest
#

how to setup a on_message event in a cog

#

@commands.Cog.listener()
async def on_message(self,message):
a=message.content
b=message.author
if message.author==self.client:
return
else:
print(a)
await message.channel.send("AALTU FAAltu")

#

error:'result' object has no attribute 'client'

soft solstice
#

self has no attribute client

cold sonnet
cold sonnet
#

you defined the class wrong

gray nest
#

no no

cold sonnet
#

show

gray nest
#

it's correct

cold sonnet
#

maybe you overwrote it then

pliant gulch
gray nest
#
from discord.ext import commands

class result(commands.Cog):

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

    @commands.Cog.listener()
    async def on_command_error(self, ctx, error):
        if isinstance(error, commands.MissingPermissions):
            await ctx.send('Sorry you are not allowed to use this command.')

    @commands.command(description = 'Kick memebers from the server. NOTE: this command is for those who have kick_members permission')
    async def kick(self,ctx, member:discord.Member, *, reason = None):
        if (ctx.message.author.permissions_in(ctx.message.channel).kick_members):
            await member.kick(reason = reason)
            await ctx.send(f'{member} was kicked.')

    @commands.command(description = 'Ban memebers from the server. NOTE: this command is for those who have ban_members permission')
    async def ban(self,ctx, member:discord.Member, *, reason = None):
        if (ctx.message.author.permissions_in(ctx.message.channel).ban_members):
            await member.ban(reason = reason)
            await ctx.send(f'{member} was banned.')




    @commands.Cog.listener()
    async def on_message(self,message):
        a=message.content
        b=message.author
        if a==b:
            return
        else:
            print(a)
            await message.channel.send("AALTU FAAltu")
            return
        
def setup(client):
    client.add_cog(result(client))```
cold sonnet
#

oh well

pliant gulch
#

__init__ not init

gray nest
#

done

cold sonnet
#

if message.author == message.content?

paper sluice
#

👋

gray nest
#

infinite loop

silver magnet
soft solstice
#

message.author == client:

#

maybe?

cold sonnet
#

self.client.user

gray nest
#

THANKS!

opal cosmos
#

within a command, how do i test if the ctx.author.id is in a json file

astral lily
#

Hello is anyone here

formal basin
opal cosmos
velvet compass
#

!ytdl we won't help with projects using that btw

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)
astral lily
#

uh okay

formal basin
astral lily
#

know it now

paper sluice
opal cosmos
paper sluice
#

It's just like a dict

silver magnet
paper sluice
opal cosmos
#

thx

opal cosmos
#

"965624886657695804" : what here?

sacred oyster
#

there's any way to disable the "banned from api temporaly"?

velvet compass
#

Probably not. Sounds like a rate limit or straight up ban from accessing an API. What were you doing prior to that?

flat swallow
#

Hi I am making a Discord bot and I am trying to make a Dead Chat Ping function that pings @ here if there is no activity in the server for 1 hour.

if message.content.startswith("$EnableDeadChatPing"):
      if datetime.datetime.now() - message.created_at == 5:
        await message.channel.send("@here")
      await message.channel.send("Enabled Dead Chat Ping")

Here there are no compiler errors and the Enabled Dead Chat Ping message comes out too but the @ here ping doesn't which it is supposed to if 5 seconds pass, which I have done as a test

opal cosmos
#

hey so um i tried asking someone about this and he hasnt replied so i still ned help. i have this command:

@bot.command()
async def test(ctx):
  with open("premium.json") as file:
    file = json.load(file)
    if ctx.author.id in file:
      await ctx.send("Testing")

and this in my json file:

{
  "965624886657695804" :
}

what goes after the colon?

paper sluice
slate swan
opal cosmos
paper sluice
#

Just replace { with [

#

And remove the semicolon

opal cosmos
#

ok

#
[
  "965624886657695804"
]
#

still no work, but no error either

paper sluice
#

What doesnt work?

opal cosmos
#

it wont send the message after testing if my id is in the file

paper sluice
#

Remove the " from json

opal cosmos
#

thx it works

#

json is weird

little ivy
#

Why doesnt it take the get_role thing?

opal cosmos
#

ok so i wanna delete the users command after its used but it says that ctx has no attribute "delete"

slate swan
#

!d discord.Message.delete

unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
slate swan
#

!d discord.ext.commands.Context.message

unkempt canyonBOT
#

The message that triggered the command being executed.

Note

In the case of an interaction based context, this message is “synthetic” and does not actually exist. Therefore, the ID on it is invalid similar to ephemeral messages.

slate swan
#

it would be

await ctx.message.delete()
opal cosmos
#

thx

slate swan
#

Trying to make a bot clear command.

put it blank im trying to make it where my bot checks if the author of the message is another bot. if it is a bot they'll delete their message. i'm not completely sure what CHECK to do for it though

chilly igloo
#

!s discord.help

jade bay
#

Can you host a discord bot on this

chilly igloo
#

Yes

#

I am currently

jade bay
#

oh really?

chilly igloo
#

I think

cedar niche
#

Hello m a new memebr on this server

slate swan
#

so there's not a if message.author.bot = True ?

#

for a leveling system in dpy they just give the bot xp as well?

#

no no

#

what im trying to get at is like a purge command, but instead of it purging USER messages it purges bot messages. i've seen it done wit multiple bots that use dpy

pliant gulch
#

!d discord.TextChannel.purge you can pass a check to the purge call

unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.

Changed in version 2.0: The `reason` keyword-only parameter was added.

Examples

Deleting bot’s messages...
cedar niche
pliant gulch
#

E.g lambda message: message.author.bot

slate swan
#

ag

pliant gulch
shell dune
#

Has anyone here made a backend for their bot? Im trying to make a SQl DB on a server, build an API on it. Since im using python for my bot would flask/django be solid for backend?

jade bay
frozen patio
#

I run my bots on a 30gb VPS

cedar niche
cedar niche
#

do i need a hosting service that has python on it

cedar niche
frozen patio
cedar niche
frozen patio
#

But I have a few test servers

cedar niche
#

ok ok send me bro

frozen patio
#

DM me then

cedar niche
#

how can i do that

#

m new o discord

frozen patio
#

and click message

#

and send a message

cedar niche
#

i sent u a friend req

crisp shoal
#

so I have a command with buttons here,
after I restart the bot it works and responds normally, reacts to the buttons etc.
but if I try to run the command again, it doesn't respond. not on any guild or channel

#

how can I stop it from listening to button callbacks, how do I stop them with the view.stop

slate swan
#

if you subclassed View just do self.stop()

#

if not just use an instance of View

silver magnet
#
async def reddit(ctx, saymsg):
    subredd = reddit.subreddit(f"{saymsg}")
    for post in subredd.random_rising(limit=1):
        await ctx.send(post.title + "\n" + post.url)```
trying to make a bot that can browse a subreddit, but i dont seem to find a way to do it
sacred oyster
sacred oyster
#

"rust > python" ?!

exotic bear
crisp shoal
#

@slate swan how do I subclass View

sacred oyster
exotic bear
crisp shoal
#

bro why can't it respond to the command again even after stopping the view from every button

exotic bear
crisp shoal
#

why can't my bot reply even after stopping every view

#

it works after restarting bot but then doesn't reply anymore

#

doesn't work in any guild or channel anymore

spice adder
#

I'm trying to make a command that edits the description of an embed in a specific channel, and I'm not really sure what I'm doing wrong, but it says

@client.command()
@commands.has_role('Manager')
async def reason(ctx, msgID: int, *, arg):
  channel = client.get_channel(824390745775276092)
  message = channel.get_message(msgID)
  old = message.to_dict()
  edit = re.sub("(\'description\': \'.*\')", str("\'description\': \'" + arg + "\'"), old)
  new = discord.Embed.from_dict(edit)
  await ctx.message.edit(embed=new)
``` Error is that TextChannel has no attribute get_message. I got the channel.get_message part from this channel
charred laurel
#

hi, im making a discord bot to send a dm to a user. but i got this error: RuntimeWarning: coroutine 'Discord_Send.dm_codes' was never awaited Discord_Send().dm_codes() RuntimeWarning: Enable tracemalloc to get the object allocation traceback
this is my code: ```class Discord_Send:

async def dm_codes(self):
    print("Dm'ing codes")
    user = Data.author
    embed = Embed(
        description = f"**[10% OFF]**",
        color = Color.blue()
        )

    _str = ```"```yaml\n"
    for code in Email.codes:
        _str += f"{code}\t10% OFF\n"
    _str += "```"```
    embed.add_field(name = 'Codes:\t', value = _str, inline = False)

    await user.send(embed=embed)
cold sonnet
#

you call the command yourself?

charred laurel
crisp shoal
#

guys I found out what my issue was

cold sonnet
opal cosmos
#

how to tell if a user has voted on top.gg

chilly igloo
#

!resources

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.

velvet haven
#

How to set volume of the bot in vc channel

idle laurel
#

are the delays from /slash command down to the code or discord alone staling them kinda thing?

strong vector
#

in the new update can i take the user input? (not wait msg to take input)

brave forge
#

if you throw a bunch of links into a json file, the program itself will be able to randomly get them from there and use them in embed ?

strong vector
#

1.load the links list from the json file

#

wait i didn't use discord from a long time

#

2.use the random library
3. use the fun random.choice(linksList)

slate swan
#

or just use a list

slate swan
#

!d input

unkempt canyonBOT
#

input([prompt])```
If the *prompt* argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EOF is read, [`EOFError`](https://docs.python.org/3/library/exceptions.html#EOFError "EOFError") is raised. Example:

```py
>>> s = input('--> ')  
--> Monty Python's Flying Circus
>>> s  
"Monty Python's Flying Circus"
```  If the [`readline`](https://docs.python.org/3/library/readline.html#module-readline "readline: GNU readline support for Python. (Unix)") module was loaded, then [`input()`](https://docs.python.org/3/library/functions.html#input "input") will use it to provide elaborate line editing and history features.

Raises an [auditing event](https://docs.python.org/3/library/sys.html#auditing) `builtins.input` with argument `prompt` before reading input...
strong vector
slate swan
#

this?

brave forge
strong vector
slate swan
strong vector
slate swan
brave forge
#

how to write links correctly in a json file ??

slate swan
#

if youre gonna write links just use a list

strong vector
slate swan
#

ah

strong vector
unkempt canyonBOT
slate swan
#

like the coro Bot.wait_for? im kinda confused sorry

strong vector
unkempt canyonBOT
#

json.dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)```
Serialize *obj* as a JSON formatted stream to *fp* (a `.write()`-supporting
[file-like object](https://docs.python.org/3/glossary.html#term-file-like-object)) using this [conversion table](https://docs.python.org/3/library/json.html#py-to-json-table).

If *skipkeys* is true (default: `False`), then dict keys that are not
of a basic type ([`str`](https://docs.python.org/3/library/stdtypes.html#str "str"), [`int`](https://docs.python.org/3/library/functions.html#int "int"), [`float`](https://docs.python.org/3/library/functions.html#float "float"), [`bool`](https://docs.python.org/3/library/functions.html#bool "bool"),
`None`) will be skipped instead of raising a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError")...
strong vector
#

ops

slate swan
#

or just use a regular list.

strong vector
unkempt canyonBOT
#

json.load(fp, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)```
Deserialize *fp* (a `.read()`-supporting [text file](https://docs.python.org/3/glossary.html#term-text-file) or
[binary file](https://docs.python.org/3/glossary.html#term-binary-file) containing a JSON document) to a Python object using
this [conversion table](https://docs.python.org/3/library/json.html#json-to-py-table).

*object\_hook* is an optional function that will be called with the result of
any object literal decoded (a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "dict")). The return value of
*object\_hook* will be used instead of the [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "dict"). This feature can be used
to implement custom decoders (e.g. [JSON-RPC](http://www.jsonrpc.org)
class hinting)...
slate swan
#

why write links in a json file then having a list

#

¯\_(ツ)_/¯

strong vector
pliant gulch
#

In the new "update" which I assume you mean discord.py v2.0, there is Modals, which allow a user to enter text and hit "submit"

#

They are only avaliable through interaction responses although

slate swan
#

idk the situation but he said about writing lists and getting a random element so

#

wait brian do you want to do <prefix><context> message here?

strong vector
slate swan
#

because you said you want to take a users input without waiting for a message so is that so?

strong vector
#

but thx i don't think there is a way

placid skiff
#

What do you want to do? D_D

slate swan
#

refer to what nullptr said

strong vector
slate swan
#

modals!

strong vector
#

excuse me, what? english

#

ooooh okay nice okimii thanks

opal cosmos
#

why is this wrong?

  def check(m):
      return m.content == 'Join' and m.channel == ctx.channel and m.author == not ctx.author
#

error says that == not ctx.author is wrong

sick birch
#

That's incorrect syntax

#

Well technically it is correct

opal cosmos
#

but idk what would be right

sick birch
#

But it doesn't do what you want it to do

opal cosmos
#

then how do i make it do what i want it to do

sick birch
#

m.author != ctx.author

opal cosmos
#

ok

oblique adder
#

I have a verification command (slash command)

How do I know If there is an ongoing captcha which is not complete and won't send another one if there is so (until timer run out).

What is the best way ?
Use slash command and discord modals

sick birch
#

Or, not m.author == ctx.author

sick birch
oblique adder
#

or should I just do the ez but not bad way to do it like storing user id in json file inside array ?

opal cosmos
#

ok so i have this annoyingly complex battle command and it wont send the winning message at the end unless i say FIRE

  @commands.command(name="battle")
  async def battle(self, ctx: commands.Context):
    await ctx.send(f'The next person to say "Join" will fight {ctx.author.mention}')
    def check(m):
      return m.content == 'Join' and m.channel == ctx.channel and m.author != ctx.author

    msg = await self.bot.wait_for('message', check=check)
    fight = await ctx.send("To win, be the first person to say...")
    await asyncio.sleep(3)
    await ctx.send("FIRE")
    
    
    def check2(m2):
      return m2.content == 'FIRE' and m2.channel == ctx.channel and m2.author == ctx.author

    msg2 = await self.bot.wait_for('message', check=check2)
    await ctx.send(f"{msg2.author} won the fight!")
#

nvm

boreal ravine
#

fix your indents

#

they look like shit

dire folio
#

how would i check if a message is in a server rather than a dm in on_message

dire folio
#

ty

dull terrace
#

look how pretty this code is now to update my patreons for discord and get some names pepe_cheer

frozen patio
#

Why are you using repl?

dull terrace
#

who's using repl

frozen patio
#

That looks like repl 👀

dull terrace
#

it's atom with dark forest theme

frozen patio
#

Ah, sorry, looks like repl 😅

livid hinge
#

replit is slightly uglier

trim fulcrum
#

how can i make it where if you put a certain word in your status it sends a message and adds a role and if you remove that word it removes role and sends a message

strong vector
#

whats wrong with the test code?

class Test_Cog(commands.Cog):
    def __init__(self, bot):
      self.bot = bot # defining bot as global var in class
      
    @commands.Cog.listener() # this is a decorator for events/listeners
    async def on_ready(self):
      print('Bot is ready!.')
      
    @commands.command() # this is for making a command
    async def ping(self, ctx):
        await ctx.send(f'Pong! {round(self.bot.latency * 1000)}')
        
def setup(bot): # a extension must have a setup function
    bot.add_cog(Test_Cog(bot)) # adding a cog
setup(bot)
bot.run(DataV.TOKEN)

Error

exmple.py:26: RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited
  bot.add_cog(Test_Cog(bot)) # adding a cog
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
sick birch
#

You have to await add_cog() I'm guessing

#

Though I don't remember it being a coro but load_extension() was made a coro so I suppose it does make sense

strong vector
#

huh

sick birch
#

Well the error is clear enough, isn't it?

#

"coroutine 'BotBase.add_cog' was never awaited"

strong vector
sick birch
#

And what happens?

#

Can't await inside non-async function?

strong vector
sick birch
#

And setup() is supposed to be async

strong vector
#

i can't await outside or inside not-async fun

olive osprey
# trim fulcrum how can i make it where if you put a certain word in your status it sends a mess...

There are some different ways to do that, but you should check the activity of someone first of all

str(user.activity) # Not sure, but i think its needed as a string as it will return some other stuff else

I think this simply is enough, just check then what the status contains:

if str(user.activity) == "test":
    await user.send("Test")
else:
    pass

Not sure, but i think there's such an event like "on_user_update" or something

sick birch
#
async def setup(...):
  await bot.add_cog(...)
  ...
#

on_member_update

strong vector
olive osprey
#

^

sick birch
strong vector
#

err let me try

#

RuntimeWarning: coroutine 'setup' was never awaited

sick birch
#

Code?

sick birch
#

Are you calling setup()

strong vector
sick birch
#

Don't

strong vector
#

ik

olive osprey
#

what

strong vector
#

lmao

#

i didn't realize at first but brah

olive osprey
#

atleast you found the issue^^

boreal ravine
#
C:\Users\raimy\Desktop\fuck-bot>python bot.py
Failed to load extension cogs.economy
C:\Users\raimy\Desktop\fuck-bot\bot.py:28: RuntimeWarning: coroutine 'Client.run.<locals>.runner' was never awaited
  print(f'Failed to load extension {cog}')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Failed to load extension cogs.__pycach
Logged in as FarmBot#0000
strong vector
olive osprey
#

rip

strong vector
#

class Test_Cog(commands.Cog):
    def __init__(self, bot):
      self.bot = bot # defining bot as global var in class
      
    @commands.Cog.listener() # this is a decorator for events/listeners
    async def on_ready(self):
      print('Bot is ready!.')
      
    @commands.command() # this is for making a command
    async def ping(self, ctx):
        await ctx.send(f'Pong! {round(self.bot.latency * 1000)}')
        
async def setup(bot): # a extension must have a setup function
    await bot.add_cog(Test_Cog(bot)) # adding a cog

setup(bot)
bot.run(DataV.TOKEN)
trim fulcrum
#

is this good?

boreal ravine
strong vector
olive osprey
trim fulcrum
#

becuase i got indent errors

strong vector
trim fulcrum
olive osprey
#

Do you use tabs & space mixed up? You should consider only using one of those both

olive osprey
#

I recommend using tab, try to indent the code again

#

Hm, I don't see any indent problem. What does the error say where you messed it up?

trim fulcrum
#

me either

olive osprey
#

ah

trim fulcrum
strong vector
olive osprey
#

I see the problem, remove the #

strong vector
#

you coment the line

olive osprey
#

It does count the else as a part of the if statement

trim fulcrum
#

where

strong vector
trim fulcrum
#

on await?

olive osprey
#

Yes, you have it marked as comment. Remove the # from it and it should work

trim fulcrum
#

still same error

olive osprey
#

It's what I said, it looks like you used spaces and tabs mixed up, indent your code again only using tab or space

trim fulcrum
#

yea i do dat

strong vector
boreal ravine
#

what

strong vector
boreal ravine
sick birch
strong vector
sick birch
#

How do you know it didn't call?

strong vector
#

it must print to em 'bot is ready!.'

sick birch
#

Right. Did you await load_extension(...)?

strong vector
sick birch
#

What do you mean?

strong vector
#

nope i didn't

sick birch
#

Mm. Yeah you need to do that for discord.py to call your setup function

strong vector
sick birch
#

Do it in your setup_hook

#

await load_extension("filename")

strong vector
sick birch
#

The name of the file with the cog

strong vector
#

uham

olive osprey
#

lmao

slate swan
olive osprey
#

Huh, what's that?

#

Damn, is that a d.py 2.0 thing?

sick birch
olive osprey
#

never heard about it

slate swan
sick birch
#

Right, and if you're getting to the point where you're loading cogs and extensions you're not necessarily starting and should consider subclassing

slate swan
sick birch
#

(And learning if you don't know)

#

Since inheritance is one of the biggest concepts when it comes to object-oriented programming, it's quite important to know if you plan on expanding outside of just discord bots

slate swan
#

some people have it hard subclassing the bot class

#

¯\_(ツ)_/¯

olive osprey
#

Can't seem to find it, that's really crazy, I never saw it listed up anywhere nor did I saw any bot having it

#

Damn, I will test that out tomorrow, I'm still on d.py 1.73 though, hopefully it works

echo wasp
#

Is it possible to add a user, bot, and banned members counter if so where do I start

sick birch
#

await guild.bans() - for all banned users, find length to get banned members count
guild.members - for all members (including bots), find length to get all member count

#

And you can apply filters on guild.members to only get what you want

#

e.g filter(lambda x: x.bot, guild.members) for a list of all bots

#

Likewise, filter(lambda x: not x.bot, guild.members) for a list of all non-bot users

echo wasp
#

How about just numbers?

sick birch
#

len()

echo wasp
#

Example?

slate swan
#

!d len

unkempt canyonBOT
#
len

len(s)```
Return the length (the number of items) of an object. The argument may be a sequence (such as a string, bytes, tuple, list, or range) or a collection (such as a dictionary, set, or frozen set).

**CPython implementation detail:** `len` raises [`OverflowError`](https://docs.python.org/3/library/exceptions.html#OverflowError "OverflowError") on lengths larger than [`sys.maxsize`](https://docs.python.org/3/library/sys.html#sys.maxsize "sys.maxsize"), such as [`range(2 ** 100)`](https://docs.python.org/3/library/stdtypes.html#range "range").
fleet pine
#

whats the code for discord bot

echo wasp
olive osprey
echo wasp
#

^^^

fleet pine
olive osprey
#

You're new to python or the discord lib?

fleet pine
#

i find it hard to learn python idk from where to learn

fleet pine
olive osprey
#

If you’re new to Python, I suggest to start learning the basics first

slate swan
#

!resources

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.

olive osprey
#

^

fleet pine
slate swan
#

not about how much it will take you.

#

its were it would take you and how much passion you put into it and how fast you learn.

olive osprey
#

^
You're straight up stealing my words lmao

slate swan
fleet pine
#

thanks down bad!

olive osprey
#

Np^^ have fun learning Python!

mortal dove
#

Is it possible to get the cog of an app_command.Command?

slate swan
# fleet pine oh ok thanks btw

im a fast learner and it took me a bit of time about 6-7 months and it was short because ive always liked programming and ive mastered python pretty well after about a year

slate swan
#

yep

olive osprey
flat solstice
#

in dpy 2.0 how can I check if a guild is a community server? can I do something like```py
guild = self.bot.get_guild(ID)
if guild.features.community is true:

run some code```

slate swan
#

most people i talk to/friends of mine have 2+ years of experience while i have more than a year of experience

olive osprey
#

Damn, that's actually something that could help me

#

Looks like I will be much more active on here lol

slate swan
#

ive learned quickly because ive been here probably 250+days so almost daily for over a year

#

mostly helping others

#

and no helper role, mina notice me or robin😔 🙏

olive osprey
#

Crazy, what channels are you the most active in? I just sometimes look in here, or try to find a help channel where someone just has problems with the d.py basics lmao, I mostly do that when I'm bored

olive osprey
slate swan
slate swan
#

i need time to finish my event system impl😔

#

but ive seen you and you remind me of me ngl

#

you have the same knowledge as me when i had 4-5 months of experience

olive osprey
#

I see, I see, looks like we will see each other more often from now on

Good luck with your event system

olive osprey
slate swan
#

im always lurking😏

olive osprey
#

good to know

slate swan
#

even when im in school😳

olive osprey
#

Damn

slate swan
#

you remind me allot of me because of your experience and your zt pfp😳

olive osprey
#

lmao, yeah zero two is never gonna die as waifu

slate swan
#

amen 💜 🙏

olive osprey
#

Anyways, we're kinda going off-topic, I will head to sleep now anyways, good night, we will probably see each other again within the next days!

slate swan
#

Good night, i look forward to it!

cedar niche
#

hello i have this error

#

RuntimeError: SSL is not supported.

echo wasp
#

How would I rename a channel the member amount

cedar niche
#

this is the code import discord

token = 'my tok'
client = discord.Client()

@client.event
async def on_ready():
print("hey we have logged in as {0.user}")

client.run(token)

#

please help me guys

echo wasp
#

Thank you

fleet pine
#

guys i cant see my bots token

#

and they need 2fa from where

#

do i get my 2fa

boreal ravine
boreal ravine
boreal ravine
fleet pine
slate swan
#

When u hack account and see there's 2fa lol jk

fleet pine
#

wdym

boreal ravine
slate swan
#

Hi sift

boreal ravine
oblique adder
#

I suck at choosing color can anyone suggest any color combination ?

mortal dove
#

idk I think that looks pretty nice

boreal ravine
oblique adder
#

✅ < - Wouldn't that make my button look like this ?

torn sail
#

It would remove the black outline on the emoji

boreal ravine
#

yes

supple thorn
#

Master's name becomes more weirder the more i see him

sick birch
echo wasp
sick birch
#

Green on green, red on red makes it hard to tell

echo wasp
oblique adder
#

is it just me or it look a bit weird 🤔

echo wasp
oblique adder
#

can I use animated emoji in button ?

boreal ravine
#

yes, i think

boreal ravine
echo wasp
torn sail
#

!d discord.Client.get_channel

unkempt canyonBOT
#

get_channel(id, /)```
Returns a channel or thread with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
echo wasp
torn sail
#

That’s fetch_channel

unkempt canyonBOT
#

Hey @fervent shoal!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

fervent shoal
#

dam

echo wasp
#

Just get_channel(id)

torn sail
#

Yes

fervent shoal
slate swan
#

Get and fetch are different things, you dont need to await get_x methods

oblique adder
mortal dove
#

Anyone know why this command isn't registering in discord?

    @app_commands.command()
    async def helpmessage(self, inter: Interaction, cog: str = None, group: str = None, command: str = None, ephemeral: bool = True):
      #...

The cog is loaded and commands are synced

oblique adder
mortal dove
#

No

fervent shoal
#

how do i set a listen thingy

oblique adder
oblique adder
fervent shoal
#

so that the bot listens and responds instead of me doing a command

supple thorn
unkempt canyonBOT
#

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

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

Warning

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

bruh

fervent shoal
#

where did dave come from

supple thorn
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

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

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

Example...
fervent shoal
#

@commands.Cog.listener()
async def on_message(message):
print('logger module online')

@commands.Cog.listener()
async def on_message(self, ctx):
    now_utc = str(datetime.now(timezone.utc))
    now_unix =  str(time.time())
    serverNAME = ctx.guild.name
    serverID = ctx.guild.id
    userNAME = ctx.author.name
    userID = ctx.author.id
    channelNAME = ctx.channel.name
    channelID = ctx.channel.id
    message = ctx.content
#

now if i substitued the id stuff, it should work

oblique adder
supple thorn
fervent shoal
#

so remove ctx

supple thorn
mortal dove
#

btw all of my other commands do register as slash, just not this one

fervent shoal
#

replace the self too?

mortal dove
#

Oh, yes I did @oblique adder

supple thorn
fervent shoal
#

@commands.Cog.listener()
async def on_message(self, message):
now_utc = str(datetime.now(timezone.utc))

oblique adder
fervent shoal
#

i gotta now fix all the ctx after that, any idea on wht to change it too?

oblique adder
#

so wouldnt that make it a global ?

mortal dove
#

Yes

oblique adder
#

so It would take an hour have u waited that long ?

simple kettle
#

Is there a way where I can create commands that will only work if you dm the bot

mortal dove
#

The bot is in 3 servers, the effect it has on the bot is minimal

mortal dove
#

There's probably a commands. decorator for that too

fervent shoal
oblique adder
torn sail
unkempt canyonBOT
#

@discord.ext.commands.dm_only()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that indicates this command must only be used in a DM context. Only private messages are allowed when using the command.

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

New in version 1.1.
oblique adder
#

on_message doesnt take ctx

fervent shoal
#

what do i do with all the ctx under this then

slate swan
#

self is the first arg, message would be the second one

oblique adder
slate swan
#

Is there any way in which we know if we can dm the user or not

#

without sending

frozen patio
#

I do it with my modmail bot

#

with a simple contact command

slate swan
#

create_dm ?

slate swan
torn sail
#

There’s not point in create_dm honestly

slate swan
#

Oh..

slate swan
#

would be true, if the member is DM-able

#

!d discord.DMChannel.permissions_for

unkempt canyonBOT
#

permissions_for(obj=None, /)```
Handles permission resolution for a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").

This function is there for compatibility with other channel types.

Actual direct messages do not really have the concept of permissions.

This returns all the Text related permissions set to `True` except...
oblique adder
slate swan
torn sail
fervent shoal
fervent shoal
#

im not getting anything back

torn sail
slate swan
#

you can un use try except blocks

sick birch
#

That's really the only way

#

It's a library limitation

sick birch
#

Plus there's no reason for you to check if they're DMable using an if condition

slate swan
#
try:
   await send("msg")
except discord.Forbidden:
   # dms closed
#

I was finding a simpler way

#

In my ban cmd mainly

#

First send msg that ur banned then ban

fervent shoal
oblique adder
supple thorn
oblique adder
slate swan
#

Nvmd

oblique adder
# oblique adder nope you didnt ic why now
@commands.Cog.listener()
    async def on_message(message):
        print('logger module online')```
and why on_message instead of on_ready ?
also
why do you even import cProfile ?
slate swan
#

i think its an api limitation since i havent seen any library implementing a method/property to check if a Member/User is dm-able

#

Hmm

#

even from a normal user side you wont know if a user has their dms closed without actually dming them

sick birch
fervent shoal
sick birch
#

Pretty sure bots can't have friends

slate swan
#

it was in 1.7.3 im sure

supple thorn
fervent shoal
#

what is an intent

slate swan
#

removed in 2.x

slate swan
#

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

fervent shoal
#

so do i just add that ?

slate swan
#

what dpy version are you using

slate swan
fervent shoal
#

i got this code of the internet

#

wait no i am

slate swan
fervent shoal
#

its not in the imports 💀

brisk dune
fervent shoal
#

wait

#

yes, its just far down there

#

must fix the formating

#

ok so ive added the intent, still nothing

sick birch
#

Can we see the code?

fervent shoal
slate swan
#

you didn't load the cog

#

remove to load function and do bot.add_cog(CogClass(bot))

left crater
#

It’s asynchronous now

#

If your using 2.0

silver wolf
#

I wonder if most ppl are gonna be switching back to discord.py 2.0 or if they’re gonna stick with their fork library 🤔

slate swan
#

if i were to choose, id just stick with a fork

#

but I don't use any of them, hikari pog pydis_peek

brisk dune
#

I'm sticking with pycord. The difference is minimal

slate swan
#

minimal? 2.x versions of both are too different

brisk dune
#

minimal for what I need

#

:)

slate swan
#

why did you choose pycord? Slash commands?

brisk dune
#

yeah

#

tbh i just stumbled upon it, and liked it

slate swan
#

well, dpy slash commands and pycord/any fork's slash command are too different

modest harbor
echo wasp
slate swan
#

why do you want to define guild?

slate swan
echo wasp
# slate swan why do you want to define guild?
Ignoring exception in command update:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/vscode/Everything bot's/main_cogs/utility.py", line 60, in update
    await channel.edit(name=f"{len(guild.members)}")
NameError: name 'guild' is not defined

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'guild' is not defined```
slate swan
#

!d discord.Client.get_guild

unkempt canyonBOT
#

get_guild(id, /)```
Returns a guild with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
modest harbor
echo wasp
#
@commands.command(name="update", description="Updates the member count!")
    async def update(self, ctx):
        guild = self.client.fetch_guild(8048908012184977438)
        channel = self.client.get_channel(9668469890273380556900)
        await channel.edit(name=f"{len(guild.members)}")
        await ctx.send("Member count has been updated!")```
#

all i want is the member count on the vc channel

slate swan
fervent shoal
slate swan
#

just look up for a def load

modest harbor
slate swan
echo wasp
#

@slate swan

modest harbor
fervent shoal
gaunt ice
#

show the cog file

fervent shoal
final iron
#

mixedCase yikes

echo wasp
#

@fervent shoal can I see the file you start?

fervent shoal
fervent shoal
final iron
echo wasp
#

How many files you have for your bot?

fervent shoal
#

1

#

i think

echo wasp
#

@final iron I can't find guild.members can you send me doc link?

feral lichen
#

i use to have this right but my brain isnt functioning, how would i make this see if they have the administrator permission ```py
if member.permissions == administrator:
await ctx.send("")
return

final iron
unkempt canyonBOT
echo wasp
# fervent shoal 1

Well your on your own because I user multiple files not just one for cogs

fervent shoal
#

@echo wasp this is all my code

austere vale
#

how do i fix this?

  @commands.command()
  @commands.has_permissions(administrator = True)
  async def unban(self, ctx, user: nextcord.User, *, reason=None):
    await self.ctx.guild.unban(user=user, reason=reason)
    title = f"Unbanned {user}"
    description = f"I have successfully unbanned {user.mention} for reason: {reason}."
    embed=nextcord.Embed(title={title}, description=description, color=0xfd9fa1)
    await ctx.send(embed=embed)
echo wasp
#

@final iron why doesn't this work properly I only get the number 1 in guild name but it doesn't do all members code:

#
 @commands.command(name="update", description="Updates the member count!")
    async def update(self, ctx):
        guild = self.client.get_guild(8048646776012184977438)
        channel = self.client.get_channel(966846277667783380556900)
        await channel.edit(name=f"{len(guild.members)}")
        await ctx.send("Member count has been updated!")```
feral lichen
austere vale
echo wasp
final iron
#

Show them

feral lichen
austere vale
#

o

feral lichen
#

if it doesnt work lmk

austere vale
#

uhh no its still the same error

feral lichen
#

ight ill fix it

#

youre in a cog right

austere vale
#

ye

echo wasp
fervent shoal
#

still do be needing help

feral lichen
slate swan
final iron
slate swan
#

self.ctx ?

#

lmao

austere vale
#

self.ctx.guild.send?

slate swan
#

💀

final iron
#

You shouldn't be using self

austere vale
#

not even in a cog?

slate swan
#

that's not his problem

#

its a basic attribute error

#

😳self.ctx.message.author.guild

#

🗿

austere vale
#

oh but i wanted it to send in the channel that i type the command in

feral lichen
#

i use to have this right but my brain isnt functioning, how would i make this see if they have the administrator permission ```py
if member.permissions == administrator:
await ctx.send("")
return

slate swan
#
    @commands.command(name='mute', description='mute a user from all channels', usage='mute (user) [duration] [reason]', aliases='timeout')
    async def mute(self, ctx, member: discord.Member, time=None):
        role = discord.utils.get(ctx.guild.roles, name="muted")
        if role not in ctx.guild.roles:
            perms = discord.Permissions(send_messages=False, speak=False)
            await guild.create_role(name="muted", permissions=perms)
        if time:
            if self.convert(time) > -1:
                if time:
                    tempmute = self.convert(time)
                    await member.add_roles(role)
                    await ctx.send(f"**{member}** has been muted 👍")
                    await asyncio.sleep(tempmute)
                    await member.remove_roles(role)
        elif not time:
            await member.add_roles(role)
            await ctx.send(f"**{member}** has been muted 👍")

how do i make it so it sets the channel perms for the role instead of just the global role perms?

slate swan
unkempt canyonBOT
#

@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/master/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/master/api.html#discord.Permissions "discord.Permissions").

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

i did that and it was returning null values ig ill try again

austere vale
# slate swan just do `ctx.send()`

yeah i have

  @commands.command()
  @commands.has_permissions(administrator = True)
  async def unban(self, ctx, user: nextcord.User, *, reason=None):
    await self.ctx.guild.unban(user=user, reason=reason)
    title = f"Unbanned {user}"
    description = f"I have successfully unbanned {user.mention} for reason: {reason}."
    embed=nextcord.Embed(title=title, description=description, color=0xfd9fa1)
    await ctx.send(embed=embed) 
slate swan
#

ctx.guild.unban

austere vale
#

OH

#

THANK YOU SO MUCH

gaunt ice
#

hm

#

I'm tired

slate swan
slate swan
#

they always love listening to sarthak but not me like i get it hes cooler😔

supple thorn
slate swan
#

😔

supple thorn
#

oh yeah i gotta do something with sarth

#

thanks for reminding me

slate swan
#

#bansarthak 😡 ✊

gaunt ice
#

lol

mortal dove
#

Does anyone know why I'm getting this error? Code -> https://paste.pythondiscord.com/ucemasikar
I call the classes with

view = HelpMenu().add_item(CogSelect(self.bot))

Basically, I'm trying to create a modular view where I can add different parts depending on what the user is looking at (main help menu, specific cog, etc.)

final iron
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

final iron
#

Ain't no way I'm clicking on some random link

mortal dove
#

Ok I'll get new link ig, one sec

austere vale
slate swan
slate swan
#

!trace

unkempt canyonBOT
#

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

A full traceback could look like:

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

If the traceback is long, use our pastebin.

slate swan
#

see how a traceback shows the error lines?

austere vale
#

oh

slate swan
paper sluice
mortal dove
#

Does anyone know why I'm getting this error? Code -> https://paste.pythondiscord.com/ucemasikar
I call the classes with

view = HelpMenu().add_item(CogSelect(self.bot))

Basically, I'm trying to create a modular view where I can add different parts depending on what the user is looking at (main help menu, specific cog, etc.)

simple kettle
#

Is there a limit to how many .add_field you can put a embed on. cause i tried putting 37 through a loop and some are missing

torn sail
#

There is a limit

#

Not sure what it is

errant olive
#

Created my first bot.
tried to start it.
Got rate limited.
Is this normal?

sick birch
errant olive
sick birch
#

That explains it

#

Don't use replit

stray flicker
errant olive
#

why not?

sterile hamlet
errant olive
#

using discord.js on replit does not rate limit me

errant olive
torn sail
stray flicker
errant olive
stray flicker
slate swan
stray flicker
#

discord bots don't take much power anyways

sick birch
errant olive
sick birch
#

That doesn't matter

stray flicker
#

^

sick birch
#

Rate limiting is done server-side, so your wrapper doesn't matter

#

Using discord.js does not give you a higher rate limit

slate swan
sick birch
#

It's really not

errant olive
sick birch
#

Replit is notorious for being very bad at hosting

errant olive
#

so I should switch to aws?

stoic galleon
#

it's shared ip hosting it's bad

mortal dove
#

Does anyone know why I'm getting this error? Code -> https://paste.pythondiscord.com/ucemasikar
I call the classes with

view = HelpMenu().add_item(CogSelect(self.bot))

Basically, I'm trying to create a modular view where I can add different parts depending on what the user is looking at (main help menu, specific cog, etc.)

sick birch
sick iris
#

how can i add more things to a json file

sick birch
errant olive
stray flicker
sick birch
#

I personally use AWS but oracle free tier is heralded as well

#

Mostly because my bot has a dashboard and I need a domain as well

#

And I also use S3 for some features

slate swan
#

Google cloud services is a good option too

errant olive
#

I assume it's harder to use?

sick birch
#

any of the big ones really

sick birch
sterile hamlet
#

quick question has anyone made a twitter api discord bot?

sick birch
#

"twitter api discord bot" clarify?

errant olive
stoic galleon
sick birch
#

they probably have a free tier

sick iris
sick birch
#

most do just so they can rope you into their paid plans

stoic galleon
#

isn't heroku a free host

sick birch
#

Heroku is just as bad as replit

slate swan
# errant olive is it free?

yeah there's a free tier which you can use for 1 year, given that you need a Credit card/any payment validation

stoic galleon
#

mhm i feel like vps is the only good option

errant olive
errant olive
#

ill stick to aws then

oblique adder
#

can I get the id for PartialInteractionMessage ?

sick birch
#

For small-medium sized bots you can use a raspberry PI or some old laptop

slate swan
#

aws gives only one year too

sterile hamlet
# sick birch "twitter api discord bot" clarify?

so all the code is written in python, im using tweepy to stream certain users tweets in real time save them and then post to discord using a discord bot. I have a problem tho where both bots don't work together. whichever code is on top runs and the other doesnt

sick birch
#

You'll either have to thread it or find some other pub/sub method

#

And also twitter has a webhook you don't even have to write any code

errant olive
#

replit is free forever. any other service that is that?

echo wasp
# final iron No

How do I get just the count out of this? [<Member id=893853683136217118 name="Bro's SMP Bot" discriminator='7548' bot=True nick=None guild=<Guild id=8048640554184977438 name="Bro's Gun Server (Season 1)" shard_id=None chunked=False member_count=81>>]

sick birch
#

they do charge you $1 to make sure you enter a valid cc

sterile hamlet