#discord-bots

1 messages Β· Page 770 of 1

slate swan
#

i could show youpithink

final iron
#

I meant json as a database

quick gust
slate swan
final iron
#

Sqlite3?

slate swan
quick gust
#

Yes

final iron
slate swan
#

its a ui

#

making wut

final iron
quick gust
quick gust
#

i imported my file into it aswell

quick gust
quick gust
slate swan
quick gust
#

would be awesome if you could link me the extension

slate swan
#

sure

#

or just use the browserpithink

#

imo its better

#

since you can execute sql

pine crown
#

how to make a modlogs system?

quick gust
#

im just gathering suggestions right now, later I'll take a look at all and decide

slate swan
quick gust
#

thanks sensei

slate swan
final iron
slate swan
#

and is it really for moderation

#

cause discord doesnt like when you store allot of data

#

about users

#

you need a** good reason** for it

graceful gulch
graceful gulch
#

its bad practice and not really expandable

slate swan
#

select the extension from the popup when you read it

slate swan
final iron
slate swan
#

its just json isnt made for storing data

#

more like formatting it

graceful gulch
slate swan
#

i knew json wasnt for storing data and was for formatting it after i made my api wrapper lol

#

since the api when i make a request its response is always formatted in json

graceful gulch
#

im bored so i just make wrappers for random apis

slate swan
#

same

final iron
graceful gulch
#

they arent useful or already have better wrappers but i love making http clients

slate swan
#

lol my birthday is tomorrow and i start school tomorrowπŸ˜”

quick gust
graceful gulch
#

basically theres no way around it

slate swan
#

you can see it on it

graceful gulch
#

i mean u can try inheriting both of them into one but that might be a mess

slate swan
#

one subclasses select for the dropdown and one subclasses View to add the component to the view

final iron
#

What happens if I wanted to make 2 commands that use dropdown menus. Would I have to create 4 classes?

graceful gulch
#

no you can reuse the class

unkempt canyonBOT
#

examples/views/select/dropdown.py lines 44 to 49

class DropdownView(disnake.ui.View):
    def __init__(self):
        super().__init__()

        # Adds the dropdown to our view object.
        self.add_item(Dropdown())```
graceful gulch
#

yea unless u want the menus to be different

slate swan
graceful gulch
#

well then youll have to make new classes

slate swan
#

he probably wants it different

final iron
#

^

graceful gulch
#

oh i thought he meant something else

final iron
#

Alright

slate swan
#

yeah , until you dont want to apply something like on_timeout methods you can just use the instance

#

yeah

slate swan
#

@slate swan why do we we have to do ctx.bot.text
can't we just dopy await ctx.send(bot.test)?

slate swan
#

ctx.bot gives u the bot variable

#

weird syntax

#

what if I don't use init, should I still have to use ctx.bot.var??

#

!d discord.ext.commands.Context.bot

unkempt canyonBOT
slate swan
#

ahhh makes sense now

#

ah

slate swan
#

since you dont have the bot in the cog file ;)

#

self.bot is just the bot arg in your init dunder

#

or magic method

#

is it necessary to create a class to create init?

#

yea , but you dont use an init if you're a weirdo like me

slate swan
#

oh sorry i misread it

#

I don't use init

#

init is for classes

slate swan
#

you dont use it if you are nt in a class

#

^

slate swan
slate swan
#

well you can just bot.var

#

thx

#

wherever u get the bot from

#

Are we three weebs?

#

the init Constructors are used to initialize the object’s state.

slate swan
#

so ig so

slate swan
#

yw

slate swan
#

romance mostly

#

😳

#

i like anime but im not too much into it

slate swan
#

i have no time

#

exactly

#

yea same, I have just watched only 74 animes (all seasons) only till now

#

class, homework, programming is allot

#

im doing notes and texting at the same time rn

#

\πŸ‘

slate swan
slate swan
slate swan
#

LMAO

#

:)

#

yeah only 74 not allot

slate swan
slate swan
keen talon
slate swan
#

why does everyone assume sarthak is indian its funnyπŸ˜‚

slate swan
slate swan
#

i mean he is lol

slate swan
lost vine
keen talon
slate swan
slate swan
slate swan
#

yes

keen talon
slate swan
#

luckyπŸ˜”

#

kekw

#

cant be me

#

im an average american

#

well , lets wait for someone to !ot

keen talon
lost vine
slate swan
slate swan
lost vine
#

I'm asian with asian parents 😭

keen talon
unkempt canyonBOT
slate swan
slate swan
lost vine
keen talon
#

πŸ™‚

slate swan
#

what is the command for youtube music bot rules?

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
#

thx

lost vine
#

I don't hate anyone

slate swan
# slate swan thx

it breaks yt tos and as discord said if you break tos in there platform you break theres

slate swan
final iron
#

Is there any way I can remove a menu when it has been clicked on once?

slate swan
#

if some website don't have robots.txt and has no mention about scraping in any page, the we are allowed to scrap?? :}

lost vine
#

wait, music commands break youtube tos?

slate swan
slate swan
slate swan
#

ytdl takes music from yt which yt doesnt like

#

!d discord.ui.View.remove_item

unkempt canyonBOT
slate swan
lost vine
slate swan
keen talon
#

That's why many music bots are banned

slate swan
slate swan
keen talon
slate swan
#

Guys any website where I can create a GUI by something like drag and drop method and the python code is automatically generated in the background??

slate swan
slate swan
# lost vine Ughh

it can be abused by searching nsfw gifs like nd!gif okimii being cool

maiden fable
# lost vine Ughh

Remove the command -> Reapply -> Get accepted -> Add that command back

lost vine
slate swan
#

use a nsfw filter

slate swan
#

!ot do it

#

😳

slate swan
#

kinda on topic but idk

#

im pretty sure the api gives you a nsfw bool too

slate swan
maiden fable
unkempt canyonBOT
#
Nope.

Package could not be found.

slate swan
maiden fable
#

Bruh

slate swan
slate swan
slate swan
lost vine
#

Ghost ping?

slate swan
#

the praw api has it

maiden fable
#

@slate swan

slate swan
#

what can it do?

final iron
maiden fable
#

Use figma to create GUI and convert it to Tkinter python code automatically

slate swan
#

Tbh I have never made a gui in python and never knew what tkinter is

slate swan
maiden fable
#

!d tkinter

unkempt canyonBOT
#

Source code: Lib/tkinter/__init__.py

The tkinter package (β€œTk interface”) is the standard Python interface to the Tcl/Tk GUI toolkit. Both Tk and tkinter are available on most Unix platforms, including macOS, as well as on Windows systems.

Running python -m tkinter from the command line should open a window demonstrating a simple Tk interface, letting you know that tkinter is properly installed on your system, and also showing what version of Tcl/Tk is installed, so you can read the Tcl/Tk documentation specific to that version.

maiden fable
#

It's an stdlib

slate swan
#
async def meme_cmd(ctx: Context):
    """Meme command"""
    nsfw = True
    while nsfw == True:
        """Avoiding Nsfw"""
        data = await fetch_meme()
        if not data["nsfw"]:
            nsfw = False


async def fetch_meme():
    async with ClientSession() as session:
        res = await session.get(
            f"https://meme-api.herokuapp.com/gimme/{choice(['memes','dankmemes','me_irl','wholesomememes'])}"
        )
        data = await res.json()
        return data``` i used this to avoid nsfw , any better way around?
final iron
slate swan
maiden fable
unkempt canyonBOT
#

@discord.ext.commands.is_nsfw()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the channel is a NSFW channel.

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

Changed in version 1.1: Raise [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure"). DM channels will also now pass this check.
slate swan
#
while nsfw is True:
lost vine
#

THANKS

slate swan
lost vine
#

I HAVE BEEN SEARCHING FOR THIS

slate swan
#

i mostly use is for bool and None

#

not the current channel

maiden fable
#

Just use a custom check

slate swan
slate swan
maiden fable
lost vine
slate swan
#

LMAO

lost vine
#

!serverinfo

slate swan
#

#bot-commands

lost vine
#

oh

slate swan
#

lol

#

How to make the bot guess command??

#

if it is wrong

slate swan
#

and use wait for

slate swan
#

wdym?

#

@final iron read this , the VIew implementation remains same for all forks so it doesnt matter what library u r using

slate swan
#

no

slate swan
#

Lmao

slate swan
#

\πŸ‘

#

😳

slate swan
#

ashley youre way smorter then me for sure

slate swan
slate swan
slate swan
#

uhuh

slate swan
slate swan
#

use fuzzywuzzy

#

and get the command

slate swan
#

!pypi fuzzywuzzy

unkempt canyonBOT
slate swan
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

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

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

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

use this

#

O_o

slate swan
final iron
slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
#

yea ^^ it uses fuzzywuzzy

slate swan
# slate swan yes

how does wait for help in guessing which command I wanted to type??

slate swan
slate swan
slate swan
slate swan
#

how is that nothing its a guessing game

#

okimi , read their problem again pls

#

@slate swan misread the question I guess

#

prob

#

ye

#

(edited) pithink

slate swan
#

Lets save okimii further humiliation and @slate swan use fuzzywuzzy

#

mhmmmmm

slate swan
slate swan
slate swan
slate swan
final iron
# slate swan yea , its same!

But in the example its inheriting disnake.ui.View for the class when I'm inheriting disnake.ui.Select for my class

slate swan
final iron
#

Sorry if I'm asking dumb questions. Never worked with this stuff before

slate swan
#

ill give you a short example wait

#

you want to disable the select as soon as a option is selected right?

final iron
#

Yup

fervent fable
#

I need help

slate swan
#

with

fervent fable
#

Python code for this discord bot im making

slate swan
#

error?

fervent fable
#

it dosent have one just wont work

slate swan
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / b
ZeroDivisionError: division by zero

The best way to read your traceback is bottom to top.

β€’ Identify the exception raised (in this case ZeroDivisionError)
β€’ Make note of the line number (in this case 2), and navigate there in your program.
β€’ Try to understand why the error occurred (in this case because b is 0).

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

slate swan
boreal ravine
#

cringe

fervent fable
#

okay hold on please

quick gust
#

Be more precise, what code do you have, what are you trying to do, what is the error (if any)

slate swan
#

thonk

quick gust
slate swan
quick gust
#

yeah sorry buddy

fervent fable
#

-1

Hi so I am currently working on a command in Discord.py where if you do ".methodss" it will show every single method that has been put into a json file here is a better example: .methodss <--- command Method list method 1 method 2 method 3

I hope that gave you a better view of what im trying to do but its not working also there is NO ERRORS IN THE CMD here is the code

#Add a Method to the json string command
@bot.command()
@commands.has_role('Reseller')
async def addmethod(ctx,api, method):
methods = await get_method_data()
api = methods
methods = {}
methods['Method'] = method
methods['api'] = api
with open("methods.json", "w") as output:
json.dump(methods,output)
await ctx.channel.purge(limit=1)
embed = discord.Embed(title=f'{method} has been added to list', color=0x000000)
await ctx.send(embed=embed)
And then here is the command that will print all of the methods from the Json file

@bot.command()
async def methodss(ctx):
methods = await get_method_data()
method = methods['Method']
em = discord.Embed(title = "B")
em.add_field(name = "Methods", value = method)
await ctx.send(embed = em)
Also here is the "get_method_data" function

async def get_method_data():
with open("methods.json", "r") as f:
methods = json.load(f)

return methods

Please help me find where I messed up in this code thank you so much!!

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

fervent fable
#

where did I mess up?

#

ok

boreal ravine
#

guys give me command ideas

slate swan
slate swan
final iron
final iron
boreal ravine
fervent fable
#

-1

Hi so I am currently working on a command in Discord.py where if you do ".methodss" it will show every single method that has been put into a json file here is a better example: .methodss <--- command Method list method 1 method 2 method 3

I hope that gave you a better view of what im trying to do but its not working also there is NO ERRORS IN THE CMD here is the code

#Add a Method to the json string command
@bot.command()
@commands.has_role('Reseller')
async def addmethod(ctx,api, method):
    methods = await get_method_data()
    api = methods
    methods = {}
    methods['Method'] = method
    methods['api'] = api
    with open("methods.json", "w") as output: 
        json.dump(methods,output)
    await ctx.channel.purge(limit=1)
    embed = discord.Embed(title=f'{method} has been added to list', color=0x000000)
    await ctx.send(embed=embed)

And then here is the command that will print all of the methods from the Json file

@bot.command()
async def methodss(ctx):
    methods = await get_method_data()
    method =  methods['Method']
    em = discord.Embed(title = "B")
    em.add_field(name = "Methods", value = method)
    await ctx.send(embed = em)
Also here is the "get_method_data" function

async def get_method_data():
    with open("methods.json", "r") as f:
        methods = json.load(f)

    return methods

Please help me find where I messed up in this code thank you so much!!

slate swan
slate swan
boreal ravine
#

eco is boring

slate swan
#

make an rbnb server 🧠

fervent fable
#

??

lost vine
boreal ravine
#

whats an rbnb

fervent fable
#

what did i do wrong??

boreal ravine
slate swan
#

😩

boreal ravine
#

whats that for

fervent fable
#

scroll up sift

slate swan
lost vine
fervent fable
#

bnruj

slate swan
#

lol

lost vine
#

Use APIs is fun

boreal ravine
boreal ravine
slate swan
fervent fable
#

read it

slate swan
#

how do i make a command which makes commands for me

lost vine
slate swan
fervent fable
#

ITs nhot printing out all the data from the json string

lost vine
boreal ravine
#

roleplay?

slate swan
boreal ravine
slate swan
#

thats the smort thing about it

#

😩

boreal ravine
slate swan
lost vine
#

THen you have to

slate swan
#

no , i want the command to make commands for me Exit

slate swan
#

something like copilot

#

im bored

keen talon
lost vine
#

wait @slate swan your kakashi sharingan banner put me into magic

keen talon
boreal ravine
#

stop going off-topic

next swift
#

Is there a way to make a bot where i use a command in a different server,
it searched my server and checks if they are in that server,
then send the response at all?

final iron
#

@slate swan It doesn't disable the menu

lost vine
slate swan
final iron
#

Just doesn't do anything

keen talon
lost vine
final iron
#

Wait

#

I think this was my fault

slate swan
boreal ravine
next swift
lost vine
final iron
#

I may of fixed it

#

User error

slate swan
#

anyone has apis i can make a wrapper for?pithink

slate swan
#

wtf?

boreal ravine
slate swan
slate swan
slate swan
lost vine
boreal ravine
slate swan
final iron
#

Yeah its not disabling it

slate swan
clear epoch
#

:V jIHI

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.

lost vine
boreal ravine
next swift
slate swan
final iron
boreal ravine
#

πŸ‘

slate swan
lost vine
boreal ravine
slate swan
#

ik i am🧠

#

big bren

next swift
lost vine
final iron
lost vine
#

Lmao

slate swan
lost vine
slate swan
slate swan
# lost vine Ohh

discord doesnt like it when the bot is connecting to the gateway and you make a request

boreal ravine
slate swan
#

so it disconnects you

lost vine
#

Disconnect

slate swan
lost vine
#

that makes me remember replit

keen talon
final iron
boreal ravine
#

which line

final iron
#

Which line what

boreal ravine
#

where you disable the view

keen talon
slate swan
boreal ravine
#

on_ready triggers when the bot is fully connected to the gateway

slate swan
boreal ravine
lost vine
#

Someone request me a good API for Manga Searching please!

brisk brook
#

How do I keep appending to a list

boreal ravine
sick birch
final iron
sick birch
#

hence why people recommend against changing presence in on_ready

boreal ravine
slate swan
lost vine
pliant gulch
final iron
sick birch
keen talon
lost vine
brisk brook
slate swan
grim oar
sick birch
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

['test']
pliant gulch
boreal ravine
brisk brook
lost vine
grim oar
#

Well yeah then use that

boreal ravine
#

@final iron isn't it obvious already? did you call the disable_select method

brisk brook
#

Idk how to do that

lost vine
grim oar
final iron
boreal ravine
#

functions inside of classes are called methods

brisk brook
#

@sick birch do you get what I mean?

final iron
#

Ah

sick birch
#

every time you call the command .append gets called and a new element gets added again

lost vine
slate swan
#

im gonna make a wrapper for that api maybe make it async and actually wrap the whole api like kayle said

sick birch
#

!e

x = []
def appendToList:
  x.append("test")

appendToList()
appendToList()
appendToList()
unkempt canyonBOT
#

@sick birch :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     def appendToList:
003 |                     ^
004 | SyntaxError: invalid syntax
brisk brook
sick birch
#

hmph

slate swan
sick birch
#

i did a dumb

#

!e

x = []
def appendToList():
  x.append("test")

appendToList()
appendToList()
appendToList()
unkempt canyonBOT
#

@sick birch :warning: Your eval job has completed with return code 0.

[No output]
slate swan
#

methods are like that in ruby lol

sick birch
#

well you know what happens

#

i haven't done python in a while lol

slate swan
#

lol

sick birch
brisk brook
final iron
sick birch
slate swan
final iron
#

I just started using menus and its 12:15

#

So I'm blanking

lost vine
brisk brook
#
@client.command()
async def buy(ctx,item):
    with open("economy.json","r") as f:
        users = json.load(f)

    users["bag"] = []
    users["bag"].append([x, x]])

    with open("economy.json","w") as f:
        json.dump(users, f)
#

this is what I'm trying to do

sick birch
#
@commands.Command()
async def cmd(...):
  print(ctx.bot.x)

Out:

Hello, world!
sick birch
#

Oh you're loading from json?

brisk brook
#

yeah

slate swan
sick birch
#

Obligatory but it's highly discouraged using json for this

brisk brook
#

the bot is used on one server

sick birch
#

instead of setting users["bag"] = [] just append without resetting it first

brisk brook
#

i see

#

how will I create bag then?

sick birch
#

if that user doesn't have a bag make one

brisk brook
#

mmm

#

I see thank you

#

THANKS FOR SOLVING THE PROBLEM

#

I have been trying to figure the problem out for a while

#

the solution is as simple as I thought

#

but my knowledge of python is a bit limited, thanks

final iron
royal oar
#

If soemone leaves my server how would i get the bot to delete their information off my Json file?

slate swan
#

!d discord.on_member_remove use this event

unkempt canyonBOT
#

discord.on_member_join(member)``````py

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

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

it gives you a member object

#

use its attributes and remove the data just like you added

royal oar
#

mlk thank you

royal oar
slate swan
#

the user was not in the json

royal oar
#

it is in json that was the thing?

#

The json held their info
{"Their ID": {"wallet": 0, "bank": 0}}

slate swan
#

well json holds the string form of the id

#

not int

royal oar
#

hmm

boreal ravine
#

why use JSON as a database

red sundial
#

don't use JSON as a database lol

quick gust
#

yep

royal oar
red sundial
#

JSON is definitely not the way you wanna go tho

royal oar
#

I know ive been told

#

but its the only thing thats working

red sundial
#

why not use something like mongoDB

#

its pretty simple

#

and good for scalability

royal oar
red sundial
#

what problem are you facing?

royal oar
#

Idk cause after i started using it no errors would go through my terminal even though there were errors

#

i even made it so it would send errors and nothing came through

red sundial
#

huh thats weird

royal oar
#

thats what i thought

red sundial
#

that never happened to me

royal oar
#

so i went back to son

#

Json

red sundial
#

maybe google it

royal oar
#

i did try nothing came up

red sundial
#

or stackoverflow

royal oar
#

hmm ill have to try that

royal oar
#

that

cerulean quest
#

hello, iv been trying to work on a discord bot, and am currently facing quite a big problem. im using pycharm and am trying to install the discord module to proceed with my bot, although im not that famailiar with pip, im actually following a guide and when i look at the guide it says to install pip i must do curl https://bootstrap.pypa.io/get-pip.py > get-pip.py altho it doesnt work and says this ERROR: This script does not work on Python 2.7 The minimum supported Python version is 3.6. Please use https://bootstrap.pypa.io/pip/2.7/get-pip.py instead.

#

so i have been trying to fix this with some friends for around 2 hours

#

and i have no clue what to do

#

if anyone can help me that would be much much appriciated

#

iv been struggling with this for quite a while

#

My dms are open

#

I am not using python version 2.7 nor do i have any files related to it

#

I tried uninstalling but nothing works

red sundial
#

@cerulean quest do you have python installed in your computer?

cerulean quest
#

Yup, im using macOS

red sundial
#

then you have pip installed too

cerulean quest
#

Yessss

red sundial
#

just do pip install discord.py

#

in your terminal

cerulean quest
#

In the terminal?

boreal ravine
cerulean quest
#

Oh that explains it

red sundial
#

i don't think dpy works with python 2.7

cerulean quest
#

Well i also have pycharm 3.10 could i run anything in that?

red sundial
#

pycharm is just an IDE

#

its not python

cerulean quest
cerulean quest
red sundial
#

you sound like you're very new, you shouldn't really be making discord bots right now

#

its an intermediate library

cerulean quest
#

So i just install 3.6 and then run the pip install discord.py cmd?

red sundial
#

learn about OOP and asyncio first

red sundial
cerulean quest
red sundial
#

good luck!

cerulean quest
#

Thanks!

#

I have actually made quite a few programs, my next one is this bot, so thats why i seem kinda low level, never worked on something like this before

#

Anyway, thanks for all the help!

#

Cya

dreamy sluice
#

How do I reset the cooldown of a certain command? (Nextcord)

sage otter
#

!d discord.ext.commands.Command.reset_cooldown

unkempt canyonBOT
sage otter
#

i doubt there’s any difference since it’s a fork. Just change the names.

dreamy sluice
#

Mkay

#

How do I implement this btw?

#

@sage otter

#

ok nvm

#

I got it, thanks

boreal ravine
#

get command object

#

use reset_cooldown method

#

get context

#

pass it inside the reset_cooldown's postional arguments

dreamy sluice
#

Thanks

#

Wait, it's not working

boreal ravine
#

?

ruby flame
#

hey, can we use slash commands in dissnake? like if we put a slash then our bot should show in the menu and not a prefix"/"

wary ice
#
buttons = buttonsbot(bot)
ActionRow
ButtonType```
#

why i have a problem here

slate swan
ruby flame
royal oar
royal oar
slate swan
#

hello. I have a command with a button whick works just fine. But when i restart the bot, i have to resend the command in order for the button to work. How can I fetch the message id and if that id exists, then add the button?

#

just fetch the msg and edit it with a new view

velvet tinsel
dreamy sluice
slate swan
unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
maiden fable
#

Why to fetch...

dreamy sluice
#

doing ctx.command.reset_cooldown(ctx) fixed the issue

slate swan
maiden fable
#

Just do

msg = ctx.send(...) 
await msg.edit(...) 
slate swan
maiden fable
#

Hmm, I guess he should also look into persistent views

slate swan
#

the heck is that

maiden fable
maiden fable
#

mhm

slate swan
#

pretty cool

maiden fable
#

Β―_(ツ)_/Β―

slate swan
#

okay i am lost. What should i do?

maiden fable
#

....?

amber hedge
#

from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)

amber hedge
maiden fable
#

Β―_(ツ)_/Β―

slate swan
#

lmao

amber hedge
slate swan
#
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended nded to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, thenider  consider disabling the privileged intents instead.```
spring flax
#

enable them on the developer portal

royal oar
#

How would I get the channel to be a live a counter? I thought a code like this would work

@commands.Cog.listener
    async def on_guild_join(self):
        channel = self.client.get_channel(ChannelID)
        await channel.edit(name=f"Counter: {str(len(self.client.guilds))}")
sage otter
#

Do people even read errors now a days.

spring flax
#

?

slate swan
#

Can command names start with a number?

maiden fable
#

Sure

slate swan
#

Perfect

untold token
#

Yeah

maiden fable
#

Just use the name kwarg in the decorator

spring flax
#

put it as aliases, I think

#

or that

slate swan
untold token
#
@bot.command(name="3")
async def three(...):
  ...
#

Like this

slate swan
#

Async def 3:

sage otter
untold token
#

That's not possible

amber hedge
slate swan
#

Or does the discord.py follow the py variable name ruels?

#

ok

untold token
#

Python doesn't allow you do that

slate swan
#

yea

quick gust
spring flax
#

that should work, I believe

sage otter
#

why. If he actually wants the command name to start with a number he should just use name.

amber hedge
slate swan
slate swan
sage otter
#

That’s what I said AMshrug

slate swan
#

sorry'I didn't read that wobbly_wobbly

amber hedge
slate swan
spring flax
#

send screenshot of what you are looking at

slate swan
#

Β―_(ツ)_/Β―

spring flax
# amber hedge

select the application of the bot you are using which you ran your code and it raised that error

#

then press Bot on the side

#

scroll a bit down

#

and enable these intents

amber hedge
lunar quail
#

Would repeatedly calling guild.emoji_limit and guild.emojis get me rate-limited? or is it fine since it's not a api call?

quick gust
#

yes

#

pip install discord

quaint thistle
#

iis it possible to make a bot that runs the whole server??

quaint thistle
#

so it could log actions and stuff

#

why?

#

oh ok

#

well i just want a bot for my server but im struggling to code it

#

damn.

#

i did but my command prompt aint working

#

idk why

#

huh?

#

go on...

#

how do i import a module

#

what is a module πŸ’€

#

yo idk what you mean im just gonna try something else

#

nope.

#

im slow

royal oar
# spring flax why is there no guild argument

Im Trying to make a counter Like a member Count Channel but for the amount of guilds my bot is in, I can get it to send me a message telling me that its in how many servers:

@commands.command()
    async def server(self,ctx):
        await ctx.channel.send("I'm in " + str(len(self.client.guilds)) + " servers!")

So i tried implementing that to make this code:

@commands.Cog.listener
    async def on_guild_join(self):
        guild = self.client.get_guild(ID) #idk how im gonna use this
        channel = get(self.client.get_all_channels(ID))
        await channel.edit(name=f"Counter: {str(len(self.client.guilds))}")
        return
#

i havent been able to work that out

quick gust
#

install pip, google how to do it

royal oar
#

...

pine crown
#
@slash.slash(name="BotInfo", description="Shows Bot Info.")
async def BotInfo(ctx):
  embed=discord.Embed(color=0x8400a8, title="PexiBot Invite Link!", description="Join PexiBot server and report bugs!")
  components=[[Button(style=ButtonStyle.URL, label="βœ… Support Server", url="google.com"), Button(style=ButtonStyle.URL, label="🌐 Website", url="google.com")]]
  await ctx.send(embed=embed, components=components)

why does this not create a new slash command? the other slash commands i do appears

quick gust
#

iirc slash commands take a bit to appear globally

pine crown
#
@slash.slash(name="BotInfo", description="Shows Bot Info.")
async def BotInfo(ctx):
  embed=discord.Embed(color=0x8400a8, title="PexiBot Invite Link!", description="Join PexiBot server and report bugs!")
  components=[[Button(style=ButtonStyle.URL, label="βœ… Support Server", url="google.com"), Button(style=ButtonStyle.URL, label="🌐 Website", url="google.com")]]
  await ctx.send(embed=embed, components=components)

why does this not create a new slash command? the other slash commands i do appears

pine crown
quick gust
#

(if i remember correctly)

quick gust
green bluff
#

how do limit the wlr to only 4 letters including decimal

quick gust
#

If someone has an answer for you, they will respond

pine crown
#

i set it only one time

#

oh

#

bruh, it doesnt even work when i send the command without slash

quick gust
tame schooner
#

Hello!

quick gust
tame schooner
#

Yup

#

import hikari
import lightbulb

bot = lightbulb.BotApp('My Beautiful Token Here',
default_enabled_guilds=(923476093414039584)
)

@bot.listen(hikari.StartedEvent)
async def on_started(event):
print('Bot has started!')

@bot.command
@lightbulb.command('ping', 'Says pong!')
@lightbulb.implements(lightbulb.SlashCommand)
async def ping(ctx):
await ctx.respond('Pong!')

bot.run()

#

What wrong is that?

quick gust
#

No idea how hikari works, sorry

tame schooner
#

okay

quick gust
#

I do know someone who knows his ways with hikari, they are active here aswell so I guess you just gotta wait since I don't want to ping them

pine crown
#

): im upset

#

i am not able to create commands anymore.. sigh

#
@client.command
async def Inf(ctx):
  embed=discord.Embed(color=0x8400a8, title="PexiBot Invite Link!", description="Join PexiBot server and report bugs!")
  await ctx.send(
      embed=embed,
      components=[
          Button(style=ButtonStyle.URL, label=":white_check_mark: Support Server", url="https://google.com"),
          Button(style=ButtonStyle.URL, label=":globe_with_meridians: Website", url="https://google.com")
      ],
  )

bu i made the command!! ):

modern fiber
#

Why this doesn't seem to work?

manic wing
#

or discord - same shit

modern fiber
velvet tinsel
#

!pypi dotenv

unkempt canyonBOT
velvet tinsel
#

Have you pip installed it?

#

Also - member Intents should go in commands.Bot() iirc

limpid thicket
#

What is the parameter for options when using a subcommand in slash commands (discord-py-slash-command)?

rocky trench
#

@slate swan I've been using the system but it's not waterproof. Sometimes if u delete a message it doesn't show up in audit log

junior verge
#

I am looking for someone to make a really good bot together and grind dm me know something about database for python as well

cold sonnet
#

!rule 9

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

limpid thicket
#
@slash.slash(
  name="private",
  description="Manage a private voice.",
  guild_ids=[798251886951399487],
  options=[
    create_option(
      name="create",
      description="Create a private voice.",
      option_type=1,
      required=False
    ),
    create_option(
      name="remove",
      description="Remove a member.",
      option_type=1,
      required=False
    ),
    create_option(
      name="add",
      description="Add a member.",
      option_type=1,
      required=False,
      options=[
        create_option(
          name="member",
          description="Choose the member you want to add.",
          option_type=6,
          required=True
        )
      ]
    ),
    create_option(
      name="transfer",
      description="Transfer private voice leadership.",
      option_type=1,
      required=False
    ),
    create_option(
      name="list",
      description="List added members.",
      option_type=1,
      required=False
    )
  ]
)
``` Can anyone help? I'm receiving back: ``create_option() got an unexpected keyword argument 'options'``
cold sonnet
#

what lib is that?

limpid thicket
cold sonnet
#

it seems create_option doesn't take an options keyword argument, as the error states

limpid thicket
#

Well of course...

cold sonnet
#
    create_option(
      name="add",
      description="Add a member.",
      option_type=1,
      required=False,
      options=[
        create_option(
          name="member",
          description="Choose the member you want to add.",
          option_type=6,
          required=True
        )
      ]
    ),
#

didn't you mean to put the options outside of the create_option

#

yeah, you already did

#

so just remove the second options variable

limpid thicket
#

Wdym?

cold sonnet
#
    create_option(
      name="add",
      description="Add a member.",
      option_type=1,
      required=False),
     create_option(
       name="member",
       description="Choose the member you want to add.",
       option_type=6,
       required=True
        )
    )```
tacit horizon
#

how to reply with member name

cold sonnet
#

something like this

tacit horizon
#

author.member ?

#

what was that

cold sonnet
tacit horizon
#

ok

limpid thicket
tacit horizon
cold sonnet
reef trail
#

how do i make a command work with replies? ive tried to do

if message.reference:
``` but this brings up the issue of missing arguments
cold sonnet
limpid thicket
#

Eggy it depends how the argument passed through the function is branched off.

cold sonnet
#

it wraps all the create_option's

limpid thicket
#

If your using a command, it should be ctx.author.name

tacit horizon
#
if message.content == "e":    
        if message.author.id == 499973767846428694:
            await message.channel.send("No {author.name} :p")
            await message.delete()
cold sonnet
#

if message.author.id, here you used message.author

tacit horizon
#

OOHHH

cold sonnet
#

so what makes you use just author the next line

limpid thicket
#

Should it not be await ctx.respond()?

tacit horizon
#
await message.channel.send("No {message.author.name} :p")
cold sonnet
#

yes

limpid thicket
#

Yes.

cold sonnet
#

Yesth.

tacit horizon
#

.😭

#

r u sure ?

limpid thicket
#

No.

cold sonnet
#

yes

limpid thicket
#

Because you haven't passed the fstring.

cold sonnet
#

fawk

limpid thicket
#
await message.channel.send(f"No {message.author.name} :p")
tacit horizon
#

YES

#

duck op

echo wasp
#

error: code coming shortly

devout iris
#

How can i check specific a server for a message?

cold sonnet
#

message.guild

royal oar
#

Im trying to make a live server counter on how many servers my bot is in but im getting an error

@tasks.loop(seconds = 90) # repeat after every 90 seconds
async def myLoop():
  channel = client.get_channel(**ID**)
  await channel.edit(name=f"Counter: {str(len(client.guilds))}")
myLoop.start()

Im getting this error please help:

await channel.edit(name=f"Counter: {str(len(client.guilds))}")
AttributeError: 'NoneType' object has no attribute 'edit'
limpid thicket
#

Channel is not defined correctly.

cold sonnet
#

there's no channel with **ID** id

devout iris
# cold sonnet message.guild

it is a general answer but i need "when a specific user send "hello" on my server, bot will answer" (only my server btw)

cold sonnet
#

you don't have to convert your length to str

limpid thicket
#

The argument should be a discord.TextChannel.id passed as an int

cold sonnet
echo wasp
# echo wasp error: code coming shortly
import os
import discord
import time
import datetime
import asyncio
from discord.ext import commands
class Events(commands.Cog):
    def __init__(self,client):
        self.client = client
    @commands.Cog.listener()
    async def on_ready(self):
        for guild in self.client.guilds:
            print(guild.name)
            print(guild.me.guild_permissions)
            print(
            f'{self.client.user} is connected to the following guild:\n'
            f'{guild.name}(id: {guild.id}) \n'
            )
            members = '\n - '.join([member.name for member in guild.members])
            print(f'Guild Members:\n - {members}') 
    @commands.Cog.listener()
    async def on_member_join(self, member: discord.member):
        if member.guild.id == 804864012184977438 : return
        channels = member.guild.channels
        for channel in channels:
            if ('welcome' in channel.name.lower()) or ('joins' in channel.name.lower()): #or ('testing' in channel.name)
                 embed=discord.Embed(title=f"Welcome {member.name}", description=f"Thanks for joining {member.guild.name}!")
                 embed.set_thumbnail(url=member.avatar_url)
                 assert isinstance(channel, discord.TextChannel)
                 await channel.send(embed=embed)
    @commands.Cog.listener()
    async def on_member_remove(self, member: discord.member):
        if member.guild.id == 804864012184977438 : return
        channels = member.guild.channels
        print([channel.name for channel in channels])
        for channel in channels:
            if ('leave' in channel.name.lower()) or ('goodbye' in channel.name.lower()): #or ('testing' in channel.name):
                embed=discord.Embed(title=f"Goodbye, {member.name}", description=f"Bye {member.name} come again soon")
                embed.set_thumbnail(url=member.avatar_url)
                assert isinstance(channel, discord.TextChannel)
                await channel.send(embed=embed)```
cold sonnet
#

or if message.guild.id == blabla

devout iris
#

id as integer?

cold sonnet
#

yes

devout iris
#

K thx

#

Ummm... Also will it be command? Or event?

cold sonnet
#

it doesn't matter
if it's a command, you'll take ctx.guild

limpid thicket
#

Depends, do you want it to be executed via an event or via CLI usage in chat box.

devout iris
#

i guess it should be event cus no need for send a command for answer

echo wasp
#

i posted my code

royal oar
devout iris
limpid thicket
#

Thought it was a guild for some reason.

limpid thicket
#
channel = client.get_channel(798251886951399487) #this int should be changed to your channel id
devout iris
#

Can i add ctx param to on_message() event?

spring flax
#

for what?

slate swan
#

i have a problem when i try to make an client on event and make it on message but the problem is when i make this the rest of the code wont work

limpid thicket
spring flax
devout iris
# spring flax for what?

i want to make message waiter... i.e if a specific user send"hello" wordon specific a server , bot will dm me.

limpid thicket
spring flax
#

Why does on_message make my commands stop working?

Overriding the default provided on_message forbids any extra commands from running. To fix this, add a bot.process_commands(message) line at the end of your on_message. For example:

@bot.event
async def on_message(message):
    # do some extra stuff here

    await bot.process_commands(message)```


Alternatively, you can place your on_message logic into a listener. In this setup, you should not manually call bot.process_commands(). This also allows you to do multiple things asynchronously in response to a message. Example:

```py
@bot.listen('on_message')
async def whatever_you_want_to_call_it(message):
    # do stuff here
    # do not process commands here
``` @slate swan
royal oar
royal oar
#

no i did it i just didnt add to my text

cold sonnet
limpid thicket
devout iris
spring flax
royal oar
# limpid thicket Ok, so what's the error?
Unhandled exception in internal background task 'myLoop'.
Traceback (most recent call last):
  File "C:\Users\OzLaptops\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nextcord\ext\tasks\__init__.py", line 168, in _loop
    await self.coro(*args, **kwargs)
  File "c:\Users\OzLaptops\OneDrive\Desktop\TTS python\bot.py", line 29, in myLoop
    await channel.edit(name=f"Counter: {str(len(client.guilds))}")
AttributeError: 'NoneType' object has no attribute 'edit'
spring flax
#

if i read it right

devout iris
cold sonnet
spring flax
echo wasp
#

error: code after slowmo

limpid thicket
cold sonnet
#

!d discord.ext.commands.Bot.wait_until_ready include this in your task's first line

unkempt canyonBOT
#

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

Waits until the client’s internal cache is all ready.
devout iris
echo wasp
# echo wasp error: code after slowmo
import os
import discord
import time
import datetime
import asyncio
from discord.ext import commands
class Events(commands.Cog):
    def __init__(self,client):
        self.client = client
    @commands.Cog.listener()
    async def on_ready(self):
        for guild in self.client.guilds:
            print(guild.name)
            print(guild.me.guild_permissions)
            print(
            f'{self.client.user} is connected to the following guild:\n'
            f'{guild.name}(id: {guild.id}) \n'
            )
            members = '\n - '.join([member.name for member in guild.members])
            print(f'Guild Members:\n - {members}') 
    @commands.Cog.listener()
    async def on_member_join(self, member: discord.member):
        if member.guild.id == 804864012184977438 : return
        channels = member.guild.channels
        for channel in channels:
            if ('welcome' in channel.name.lower()) or ('joins' in channel.name.lower()): #or ('testing' in channel.name)
                 embed=discord.Embed(title=f"Welcome {member.name}", description=f"Thanks for joining {member.guild.name}!")
                 embed.set_thumbnail(url=member.avatar_url)
                 assert isinstance(channel, discord.TextChannel)
                 await channel.send(embed=embed)
    @commands.Cog.listener()
    async def on_member_remove(self, member: discord.member):
        if member.guild.id == 804864012184977438 : return
        channels = member.guild.channels
        print([channel.name for channel in channels])
        for channel in channels:
            if ('leave' in channel.name.lower()) or ('goodbye' in channel.name.lower()): #or ('testing' in channel.name):
                embed=discord.Embed(title=f"Goodbye, {member.name}", description=f"Bye {member.name} come again soon")
                embed.set_thumbnail(url=member.avatar_url)
                assert isinstance(channel, discord.TextChannel)
                await channel.send(embed=embed)```
cold sonnet
#

what are you using assert for

spring flax
# devout iris No, on server's all channels

if you want to get the message channel, do

@bot.event
async def on_message(message):
  await message.channel.send(**kwargs)

If you want to get the message guild, do message.guild

#

!d discord.Message

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

x != y Checks if two messages are not equal.

hash(x) Returns the message’s hash.
unkempt silo
#

hello,
anyone know how to get message object using message id, discord py ?

cold sonnet
spring flax
devout iris
#

Or only for check channel?

#

i'm confused about that

unkempt silo
#

without saveing obj for var

spring flax
echo wasp
devout iris
#

cus i don't want to send to channel, i want to send dm to me

spring flax
unkempt silo
cold sonnet
limpid thicket
unkempt silo
spring flax
echo wasp
royal oar
cold sonnet
unkempt silo
spring flax
# devout iris Yes
@Bot.event
async def on_message(message)
member = message.guild.get_member(put your user ID here)
await member.send("message")
spring flax
unkempt silo
cold sonnet
limpid thicket
cold sonnet
spring flax
#

you can pass in message ID/message link for the message argument

cold sonnet
#

don't include brackets

#

in !d

royal oar
limpid thicket
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.
echo wasp
spring flax
#

got it

cold sonnet
echo wasp
royal oar
#

it works thx @limpid thicket

unkempt silo
limpid thicket
cold sonnet
#

if isinstance(channel, discord.TextChannel)

cold sonnet
royal oar
#

Lmao

cold sonnet
#

it launches multiple times

limpid thicket
#

w-

echo wasp
limpid thicket
#

I do not remember that.

spring flax
unkempt canyonBOT
#

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

A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").

New in version 1.6.
cold sonnet
#

not to mention if you do api calls in/directly after on_ready, the api will hate that

unkempt silo
cold sonnet
#

the biggest chance of getting ratelimited is in on_ready

spring flax
# royal oar oof

your bot can get disconnected from the discord's API if you do API calls directly on_ready

limpid thicket
#

I remember spamming emojis so much I got 1 hour banned from API lmao.

cold sonnet
#

and if you run the code locally, you will see in the terminal that what you put in on_ready happens like daily

royal oar
#

hmm

spring flax
#

yeah, on_ready is called multiple times

limpid thicket
#

@cold sonnet Also your code you gave me doesn't work btw.

spring flax
#

@royal oar what did you want to do on_ready

cold sonnet
#

what's the outcome of your code

cold sonnet
spring flax
#

what's the task?

cold sonnet
#

just launch it before the bot runs and put wait_until_ready

royal oar
cold sonnet
#

hmm