#discord-bots

1 messages · Page 604 of 1

slate swan
#

Like reply commands

boreal ravine
#

from discord.ext import commands mb

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

I always import discord but it always says its never used in vsc

slate swan
boreal ravine
slate swan
boreal ravine
junior terrace
#

hello, i have put this into my embed field to ping a role, but it doesnt get pinged <@&816595770052182026>

slate swan
junior terrace
#

ok

#

ty

slate swan
slate swan
slate swan
#

I'm legit new to coding like I said

lofty mulch
#

Anyone can help me with this error?

discord.ext.commands.errors.ExtensionNotFound: Extension 'dev-panel' could not be loaded.

My code:

   if filename.endswith('.py'):
      bot.load_extension(filename[:-3])```
slate swan
#

im using ```py
elif member.activities[0].ActivityType.listening:
act = f"Listening"

    elif member.activities[0].ActivityType.competing:
        act = "Competing"``` and i get the error that ActivityType is not an attr, isnt it?
#

or have i put an attribute in the wrong place

boreal ravine
#

compare it 2 the class

#

!d discord.ActivityType

unkempt canyonBOT
#

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

well what do you recommend

slate swan
dusk pumice
#

Hmm? Sk what happend

boreal ravine
slate swan
#

@boreal ravine problem is listening and competing and watching arent actual activities

boreal ravine
#

hm

slate swan
#

like playing, spotify, and streaming

boreal ravine
#

!d discord.ActivityType.playing

unkempt canyonBOT
slate swan
#

!d discord.ActivityType.watching

unkempt canyonBOT
slate swan
#

..

boreal ravine
#

^

#

gtg peace

dusk pumice
#

!d discord.ActivityType.listening

unkempt canyonBOT
slate swan
#

yeah i figured the other 2 lol

boreal ravine
#

!d discord.ActivityType.watching

unkempt canyonBOT
dusk pumice
#

!d discord.ActivityType

unkempt canyonBOT
#

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

@slate swan exists :)

dusk pumice
#

Here's types

slate swan
#

so would i do something like if member.activitytype.listening is true:

#

obviously cased properly

boreal ravine
#

compare the member activity 2 the class

slate swan
#

class

#

ok so, im horrible with technical terms

boreal ravine
slate swan
#

oh i see

#

if listening -

#

so its like if "nostuff" == str(stuff):

#

A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.

brittle ingot
#

The bot tutorial is up-kept by this community. and vcokltfre is good about keeping everything up to date and has some great explanations for beginners.

slate swan
#

Hello, Im working with json. When I want to for example dump a users id into the json file how do I make it so they all stack up on eachother. Right now I wrote a message and it saved my id, then my friend wrote a message but his id overwrote my id. How can I make this not happen?

brittle ingot
#

you need to load the existing file into a dict(?) object and add to the object and then dump it.

magic ore
#

Shouldn't use json as a database

brittle ingot
#

Lovely Youtube Tutorial again 😄

slate swan
#

Doing this on my own

slate swan
visual island
#

you dont need to download anything with sqlite3 either

outer violet
#

I’m trying to put this into an embed but it’s not working, can someone help?


await ctx.send("Color {}:".format(colour_code), file=discord.File(file, "colour_file.png"))```
magic ore
#

Just because it's easy doesn't mean you should do it
And as mentioned sqlite doesn't require a server or something downloaded

#

How did you try putting it into an embed

outer violet
visual island
#

!local-file

unkempt canyonBOT
#

Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:

# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")

# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
    file = discord.File(f)

When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.

discord.Embed instances have a set_image method which can be used to set an attachment as an image:

embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png")  # Filename here must be exactly same as attachment filename.

After this, you can send an embed with an attachment to Discord:

await channel.send(file=file, embed=embed)

This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.

slate swan
brittle ingot
#

no

#

embed has a timestamp attribute.

visual island
brittle ingot
#
embed = discord.Embed(
    title= str,
    url= str
    description= str,
    color= int / hex
    timestamp= dateObj
)
slate swan
#

Thx

brittle ingot
#

either or really.

quiet coral
#

Hello, do I need a database to make a discord leveling bot ?

slate swan
#

@brittle ingot i have a question

#

how could i make something for every 12 hours it clears chat

brittle ingot
#

with tasks.loop

slate swan
#

example

quiet coral
brittle ingot
slate swan
#

i know how to use tasks

#

but would i have to fetch channel and use ctx.channel.purge or whatever

#

what is it

slate swan
quiet coral
brittle ingot
brittle ingot
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
quiet coral
slate swan
unkempt canyonBOT
slate swan
#

it takes an id ..

brittle ingot
#

you could but its not recommended as JSON isn't meant to be used as a database, its more of a way to exchange data across the web or between applications. With that said its easily corruptible

slate swan
brittle ingot
#

exactly

#

If i had any useful information for you wass it would be to learn about SQL, you can download Codeacademy app on your phone and learn SQL easily and for free. Then you will be able to apply that to database libraries like PostgreSQL, Sqlite3 or even mariaDB.

slate swan
#

More like a clear pipe exchanging water to another bucket which a db is the starting bucket which a db has encryption so it wouldn't be a clear pipe

quiet coral
#

ok thnx

brittle ingot
#

no problem

quiet coral
#
#this function checks if the command is being executed in the right channel
def check_channel(ctx):
        text_channels=['bot_commands', 'bot_commands', "🤖 bot_commands"]
        if str(ctx.channel) in text_channels:
            return True
@commands.command()
@commands.check(check_channel)

How can I do the check with a command that's in a cog is the code down bellow right?

    #this function checks if the command is being executed in the right channel
    def check_channel(self,ctx):
        text_channels=['bot_commands', 'bot_commands', "🤖 bot_commands"]
        if str(ctx.channel) in text_channels:
            return True
@commands.command()
@cog_check(check_channel)

brittle ingot
#

there is a way to make it its own check that you can call like @your-check.

#

!d discord.ext.commands.check

unkempt canyonBOT
#

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

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

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
quiet coral
brittle ingot
#
def cmdChannelOnly():
    def predicate(ctx):
        return ctx.channel.name.contains(['commands', 'cmds'])
    return commands.check(predicate)

@commands.command()
@cmdChannelOnly()
async def only_me(self, ctx):
    await ctx.send('Only you!')

according to the documentation

slate swan
#

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

slate swan
dusky pine
#

`code` for inline code

slate swan
quiet coral
brittle ingot
#

yea

slate swan
brittle ingot
brittle ingot
slate swan
#

So I downloaded pycord for the first time

#

I'm running into weird errors

brittle ingot
#

just scroll down slightly and you'll see it

brittle ingot
quiet coral
#

is pycord that trash 😂 ?

brittle ingot
#

no

quiet coral
#

yeah I am currently using disnake

brittle ingot
#

never heard of that either 😂

slate swan
quiet coral
#

what are u using ?? still with discord.py or using discord.js?

brittle ingot
#

I haven't used python since the discontinuation letter from Danny came out. Look at my status 😂

slate swan
#
import discord
import discord.ext.commands
from discord.flags import Intents

with open("secrets/token") as data:
  token = data.read().strip()

bot = discord.Bot(
  command_prefix = "$",
  intents = Intents.all()
)

bot.run(token)

Raising an error saying discord has no attribute Bot when according to the docs, it clearly does?

#

Disnake is probably the best fork out there,same syntax and most advanced

brittle ingot
valid perch
#

Pycord added discord.Bot for slash commands. So uh, yea weird

quiet coral
slate swan
#

What should my imports be? I'm waaaay too used to Hikari now. I'm trying out pycord because Hikari has super limited voice support

slate swan
slate swan
#

Oh thanks

brittle ingot
#
import discord
from discord.ext import commands

bot = commands.Bot(
    command_prefix = "",
    intents = discord.Intents.all()
)

bot.run(token)
#

!d

unkempt canyonBOT
valid perch
#

If there using pycord it's valid syntax 🤢

slate swan
#

#bot-commands

valid perch
#

Python bot requires it be exact sadly

slate swan
#

^

brittle ingot
slate swan
#

Its really bizarre since discord.Bot is definitely valid in pycord

brittle ingot
#

wait you're using PyCord?

valid perch
#

Like I've been saying... Tut

slate swan
#

Yeeeep

brittle ingot
#

lol my bad, im ded okay 😂

valid perch
brittle ingot
#

you aren't blocked.... why would you be

valid perch
#

Cos why add discord api stuff to Client

#

When you can make another Bot for it

slate swan
#

This is annoying

#

I'll try installing pycord again, but if I can't get it to work I'm going back to hikari lol

valid perch
#

You can put it in a try except. So if it's forbidden or fails it sends to ctx.channel

brittle ingot
#

use a try except block. in the except handle discord.Forbidden

slate swan
#

Use except

brittle ingot
#

oof lol

slate swan
#

Not just except add discord.Forbidden

brittle ingot
#

are you trying to member.send in the except?

#

lol

slate swan
#
try: 
await member.send()
except discord.Forbidden:
await ctx.send()
brittle ingot
#

can't say i've never done that before

slate swan
patent lark
#

just a tip:

ctx.channel.send() is the same thing as ctx.send(). no need to add channel.

slate swan
#

^

brittle ingot
#

I’d say you are human not dumb

#

And ctx.reply will reply to the ctx.message 😄

slate swan
#

^

#

Time to learn javascript lmao, this is too much trouble

#

@slate swan Btw you can use bare except but it isnt recommended as it can raise any error so add discord.Forbidden after so it will except a discord error as dms are locked

brittle ingot
valid perch
#

Learning a whole language because a single package import broke lol, fun

slate swan
#

I have to learn it at some point, might as well be now

#

There are lots of libraries I could use lol

brittle ingot
#

You could also just work with discord.py to get used to it… if you haven’t already

slate swan
brittle ingot
#

I think once I get my current projects done I’ll make a python bot and test out the current forks

slate swan
#

All you have to change is from discord to disnake or just import disnake as discord

brittle ingot
#

IK that sebkuip is collaborating with another py dev on a discord.py fork

#

Well not a fork, they’re rewriting it from scratch. Been kinda cool to see the guts of the library

slate swan
#

I installed disnake, this is working

slate swan
brittle ingot
#

Honest assessment would be to just try disnake since okimiii speaks so highly of it

#

That sounded snobby wasn’t meant to

slate swan
#

slash commands are all I really like lol

#

Using disnake, can I create prefix and slash commands under the same code?

#

Or do I have to write them separately

slate swan
#

And i think in disnake slash commands have their own decorator

brave flint
#

ctx.voice_state docs?

slate swan
#

can someone help me with the wait_for command please? the documentation is so confusing

#
        a_file = open("puzzles.txt","r")
        linenum = ""
        lines = open('puzzles.txt').read().splitlines()
        puzzleline = random.choice(lines)
        for number, line in enumerate(a_file):
            if puzzleline in line:
                linenum = number + 1
                break
        Titleline = linecache.getline(r"titles.txt", linenum)
        hint1 = linecache.getline(r"hint1.txt", linenum)
        hint2 = linecache.getline(r"hint2.txt", linenum)
        hint3 = linecache.getline(r"hint3.txt", linenum)
        incorrect = linecache.getline(r"incorrect.txt", linenum)
        solution = linecache.getline(r"solutions.txt", linenum)
        answer = linecache.getline(r"answers.txt", linenum)
        imageline = linecache.getline(r"images.txt", linenum)
        embedVar = discord.Embed(title="Puzzle No. " + str(linenum) + ":" + str(Titleline), description = str(puzzleline), color=0xE95124)
        embedVar.set_image(url=imageline)
        embedVar.add_field(name="Stuck?", value="Type 'l!hint' for a hint!", inline=False)
        embedVar.add_field(name='Want to Stop?', value="Type l!exit or l!stop to stop!", inline=True)
        embedVar.set_footer(text="A true gentleman never leaves a puzzle unsolved...")
        await message.channel.send(embed=embedVar)```
#

basically i want to check for a few commands after the await command

brave flint
#

did ctx.voice_client have disconnect?

slate swan
#

nvm i think i gotit

molten kraken
#

I'v created a webform in which someone can input data, a username. I want that data (username) to be passed to my discord bot awaiting a response from an admin. I want to execute a conditional based on the admins response. How can i make my bot listen for an input from an external source?

sullen shoal
brave flint
#

why my bot said Volume of the player set to 1% but no effect on sounds?, no error were showed

slate swan
brave flint
slate swan
#

Nvm fixed it lol

sullen shoal
#

I won't recommend making your bot like this, you should use the extension, discord.ext.commands

#

it is thousand times better

#
import discord
from discord.ext import commands

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

@bot.command()
async def puzzle(ctx):
    ...

@bot.command(aliases=["about"])
async def what(ctx):
    ...
#

for the help command, we have a very useful class to automate the process.

#

!d discord.ext.commands.HelpCommand

unkempt canyonBOT
#

class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.

Note

Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).

This means that relying on the state of this class to be the same between command invocations would not work as expected.
sullen shoal
#

@slate swan take time, try and see which is easier to maintain

slate swan
#

I fixed it but thank you

sullen shoal
slate swan
slate swan
sullen shoal
#

check that

#

100 lines of code and now i will never have to worry about the help command

slate swan
#

If your learning dpy ^

#

If your in disnake just replace discord with disnake and you'll be good or just import disnake as discord

sullen shoal
#

replacing it with disnake is recommended, reduces that 30 percent chance of getting confused

slate swan
#

Yeah

lost lagoon
#

Hello!

sage otter
#

There’s literally a python code snippet tho?

slate swan
#

lol

sullen shoal
#

use aiohttp or httpx.AsyncClient()
the python snippet there will block the code

brave flint
#

ey myxi can you help my problem?

steep estuary
#

how to add buttons in bot's profile ??

#

what are needs for that ?

sullen shoal
maiden fable
#

Now u know it (:

steep estuary
dusk pumice
#

sry

slate swan
#

How didnt you not know that if your iterating through a list of guild.members?

slate swan
#

if you mean the invite bot thingy

steep estuary
#

in new update

#

discord bots can have a Add to Server Button in the profile

sullen shoal
steep estuary
#

see

maiden fable
#

Yea

steep estuary
#

this

slate swan
steep estuary
maiden fable
#

Bruh, Sarthak said the correct way 🤦

slate swan
steep estuary
#

what is the use of members intent

slate swan
#

you dont need to code for that

steep estuary
#

it need reason

brave flint
steep estuary
slate swan
maiden fable
steep estuary
maiden fable
#

Nvm, I forgot the method

steep estuary
maiden fable
steep estuary
#

oh k

#

OAuth2 -> general

steep estuary
#

then ?

brave flint
slate swan
brave flint
#

didnt specify version so it will be newest

brave flint
steep estuary
#

default auth link

slate swan
steep estuary
#

what should i select ?

brave flint
#

hey bro

#

do you know what is the problem

slate swan
brave flint
boreal ravine
slate swan
boreal ravine
slate swan
#

in the master branch , unsure about 1.7.3

steep estuary
boreal ravine
#

ur main file*

boreal ravine
brave flint
boreal ravine
#

just go to it and play with it

steep estuary
sullen shoal
#

isn't changing volume something ffmpeg does tho

boreal ravine
#

😐

slate swan
boreal ravine
#

yes

steep estuary
slate swan
boreal ravine
steep estuary
#

what to do ?

brave flint
#

wut

slate swan
#

see , doesnt exist

boreal ravine
steep estuary
slate swan
#

did you watch any tutorial for the code?..

steep estuary
brave flint
#

why ctx.voice_state.voice.pause work fine?

boreal ravine
#

!d discord.VoiceState

unkempt canyonBOT
slate swan
boreal ravine
#

exists @slate swan

#

shell

slate swan
steep estuary
boreal ravine
#

hm

sullen shoal
#

discord doesnt reduce volume, your bot counts as a member too. pretty sure thats something ffmpeg should do tho

dusk pumice
sullen shoal
#

but idk its discord anything could happen

steep estuary
boreal ravine
dusk pumice
boreal ravine
dusk pumice
#

And no android or IOS?

sullen shoal
#

its beta

slate swan
#

dont think its implemented on android

dusk pumice
#

Ohh

boreal ravine
maiden fable
dusk pumice
#

kk

maiden fable
#

Not even message and user commands on mobile 🤦

boreal ravine
#

Its only meant for pc iirc

dusk pumice
#

tnx

slate swan
#

mobile devices always get late updates

dusk pumice
boreal ravine
#

use canary on mobile then?

maiden fable
slate swan
#

can , it still takes a long time

slate swan
maiden fable
dusk pumice
maiden fable
slate swan
sullen shoal
slate swan
boreal ravine
#

well afaik discord wont put ats button on mobile because the feature for clicking oauth links on pc makes ur life easier rather than going to another website to authorize a bot i think thats why they added the button

sullen shoal
#

they can make it on mobile too tho

slate swan
#

yea just like the listen along button for spotify

boreal ravine
brave flint
#

well how to prevent different vc people disconnect the other vc musics?

sullen shoal
boreal ravine
#

yes

#

the oauth button on mobile in discord mobile

slate swan
#

it would anyways redirect you to a browser , which kills the purpose

boreal ravine
#

yes

sullen shoal
#

they got money, they can make it easier on mobile too

#

like add button would open smth on discord mobile app

boreal ravine
#

Doesnt matter if they have money or not, if they add the button it'll just redirect u to a browser like sarthak said

slate swan
#

that would be just like the slash commands , which take 5-10 seconds just to show up on mobile devices

boreal ravine
sullen shoal
#

it doesn't need to, if they try they can do something like what happen when you click the nitro accept button

#

a floating thing where they can add bots

#

no need of browser

#

its their api they can do anythjng

boreal ravine
#

¯\_(ツ)_/¯

sullen shoal
#

thats what im saying

boreal ravine
slate swan
#

While your wearing there logo as a pfp😭

sullen shoal
#

ik the platform is shit but they made it they own it, the entire thing is their, they have money, they have paid programmers and they can even change this to a clone of onlyfans if they want thats im saying

#

they can implement new stuff

slate swan
#

I'm not prepared to properly learn disnake now lol

sullen shoal
#

you dont have to learn it just learn python

slate swan
#

you dont need to learn something new

#

I'm just so comfortable with hikari

#

I need to learn how to do voice commands on hikari, its a bit of a pain on it though

#

lol i see , remaking my bot in hikari too

slate swan
slate swan
#

I refuse to use raw hikari for that lol

#

I'm using the lavasnek_rs library

#

lightbulb/tanjun?

slate swan
#

if there is like
3 reactions on a message like 🔗⛩️💢
and i want my bot to detect the third reaction that is 💢 and wants it to react on any of the three when it detects 💢, how do it do that

sullen shoal
slate swan
#

Yes, but then I need to take the time to read the docs, thats what I mean by learn disnake

sullen shoal
#

what do you do then

slate swan
#

disnake is easier than hikari tho

sullen shoal
#

programming is all about staring the docs thats it

slate swan
#

I use hikari and am comfortable with it to a point where I don't need to check the docs regularly

maiden fable
slate swan
#

I'm trying out disnake right now, its messing with me lol

unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

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

Note

This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
dusk pumice
slate swan
slate swan
dusk pumice
#

🙂

slate swan
sullen shoal
#

the new stuff is not alot, it took me like 30 minutes to get to know the new stuff

slate swan
#

slash in hikari-lb

#

Its just the small stuff thats messing with me. Like how I'll habitually write a load function instead of a setup function for cogs

sullen shoal
#

thats crap

slate swan
#

slash in disnake

sullen shoal
#

its better than that

slate swan
#

dont think hikari is ezier

#

check v2

sullen shoal
#

easy to use

#

the docs strings are used for the actual description and param description

slate swan
#

Looks cursed

sullen shoal
#

its 12hour format the third are seconds

slate swan
sullen shoal
#

it helps during my exams

slate swan
#

What extensions do I need for Discord bots?

slate swan
#

yea i hope thommo finishes with the update soon , so i dont need to rewrite the bot again from v1 to v2

slate swan
slate swan
unkempt canyonBOT
slate swan
#

!pypi disnake

unkempt canyonBOT
slate swan
#

Thats all

#

Ok. Thank you for the help.

#

Is pip useful also?

#

Yeah

slate swan
brave flint
#

how to prefent bot disconnected from user that not with the bot when in vc?

lavish grove
#

anyone ever have this happen with an embed after editing it?

sullen shoal
#

what happened

slate swan
lavish grove
#

i just edited the message by replacing the embed lol

slate swan
#

it was like commands.Cog

sullen shoal
#

you edit to replace the embed

slate swan
lavish grove
#

fml lol

#

that makes sense

sullen shoal
#

you could use links

slate swan
#

And should I be using Visual Studio Code or PyCharm?

sullen shoal
#

your choice

lavish grove
#

idk how to encode the image to use a data string lol

slate swan
#

ill suggest vsc

sullen shoal
#

pycharm eats ram so choose a less ram heavy one if your desktop is potato

slate swan
#

vs code all the way

slate swan
#

Ok

#

And as said its not that heavy on laptops

#

How do I install the disnake and discord.py and pip that you all recommended

visual island
#

pycharm has more built-in features

slate swan
#

I found Pycharm needlessly power hungry

visual island
#

but it's really heavy

slate swan
#

Do I go to extensions on VSC and search disnake and pip and discord py?

slate swan
slate swan
#

You should learn Python before making a bot though

sullen shoal
#

and kinda looks ugly to me, i tried a few themes but it was still ugly imo

slate swan
#

Since you don't know how to install libraries, it means you never got into Python yet

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

slate swan
#

Ok well I am taking a python class right now, we just do it on a website

#

I know a decent amount of python, just not with downloaded extensions

slate swan
#

codehs

#

discord bots are hard to write before understanding oop at minimum

slate swan
#

So how do i install these? Do i go to the extensions in VSC?

sullen shoal
#

you use the python package managers for third party python modules, like anaconda, pypi

slate swan
#

VS code extensions are specific for VS code

#

@slate swan Discord bots are hard but if you want to jump to them go for it no harm in that

#

I do but I don't know how to download these things that you are telling me to.

slate swan
slate swan
sullen shoal
#

if you want to easily build a discord bot without suffering, you have to take class for python classes :p

slate swan
slate swan
#

There is an installation tutorial

slate swan
#

As simple as that

#

You can follow installation instructions here if you want disnake

sullen shoal
#

people call it bad but it really isn't those dumbfucks dont know shit how good disnake is, skids

slate swan
#

Damn, aggressive

sullen shoal
#

so if someone calls it bad, block em

slate swan
#

Never said it was bad, just said I like hikari 🤷‍♂️

sullen shoal
#

that wasnt for you tho

slate swan
#

Your correct tho

#

Who's calling it bad lol

sullen shoal
#

there are a lot of them

slate swan
#

Disnake seems like a good library. I already like it more than pycord

#

Because pycord bugged out on me

sullen shoal
#

oh yeah that shit is famous cuz of a kid on YouTube

slate swan
slate swan
#

I was reading in a thread that pycord commits without proper testing. Not sure how true that is, but its definitely put me off of it

slate swan
#

huh

#

Well, I'm still partial to disnake as far as dpy forks go lol

visual island
#

yeah it's one of the best forks currently

slate swan
#

Same syntax and pretty advance

#

Kinda basic too

#

I'll slowly write a bot in it

#

I really don't understand how to install this. I put it in the code and ran it.

#

Not sure what I'd make a new bot for, but its fun so shrek

slate swan
#

I just put it in the area I am supposed to put the code in.

#

What do you mean area?

#

@slate swan Go to cmd and type:
pip install discord
And for disnake its just:
pip install disnake

#

What is cmd?

#

To find it just press alt+r and type cmd

#

is it the same thing for mac?

#

And your gonna be in it

slate swan
#

no

#

Check the mac terminal i dont know how cuz i use windows

#

just normal mac terminal?

#

Probably, but I also don't use mac lol

slate swan
soft relic
#

I can't find game development channel lol

soft relic
#

thx

slate swan
#

Yw

#

Same for Mac

#

Just use the Terminal

#

Same commands and everything

#

well

#

Good to know

#

I'd switch to mac if I wasn't a broke bitch lol

soft relic
#

does anyone know autocode?

slate swan
#

Ahh, for me its music production lol, completely unrelated to programming

#

Thats cool

sullen shoal
#

python3 -m pip install discord should work

slate swan
slate swan
sullen shoal
#

pip is built in

sullen shoal
#

if its not available then there are tools to download it

#

startswith with "easy" or smth

slate swan
#

Mine says
"-bash: pip: command not found"

sullen shoal
#

oh

#

what did yoy try

slate swan
#

pip install disnake

slate swan
sullen shoal
#

on unix systems it should be pip3

slate swan
#

Its weird that you'd have python installed without pip 🤔

#

I have visual studio code downloaded

sullen shoal
#

if it doesn't work, python3 -m ensurepip will install pip

slate swan
#

Maybe pip isnt in environment var

#

I did that and still didnt work

#

Its saying i am on version 21.2.3 of pip and that i can go to 21.3.1

sullen shoal
#

what did you do

slate swan
#

and then when I do that, it doesnt show up

sullen shoal
#

pip is installed

#

when did it show that

slate swan
#

Yes

sullen shoal
#

which command

slate swan
#

after doing the discord py one

sullen shoal
#

command?

slate swan
sullen shoal
#

nice

slate swan
#

His pip version is out of date

sullen shoal
#

it will work fine

slate swan
#

Still recommend

#

then why does it say pip is not found

sullen shoal
#

but they could do python3 -m pip install -U pip

#

@slate swan its not in the path

#

try pip3

#

#bot-commands

slate swan
#

Pip is probably not in environment vars

slate swan
sullen shoal
#

did it show anything long

slate swan
#

Yeah

sullen shoal
#

what was the output

slate swan
#

A bunch of commands

sullen shoal
#

yeah that will work

#

now do pip3 install -U pip

#

@rigid torrent #bot-commands

slate swan
#

I dunno, I've had trouble installing libraries on older pip versions before

slate swan
slate swan
#

ok after i upgraded to pip 21.3.1 i downloaded disnake and it worked

slate swan
slate swan
#

that should work

#

Yes I have vsc

slate swan
#

Already have it

#

Great

#

Ive had vsc for like 5 months

#

Nice

#

Its a wrong token

#

Whats the full traceback?

slate swan
slate swan
#

Ok so I have downloaded discord py and disnake and pip. Do i need anything else for bots?

slate swan
#

You need to create an application in the discord developer portal and make it a bot

#

So now I can exit the terminal and create a bot on vsc?

#

Bro thats d.js

slate swan
#

Then yep, you can make a bot now!

#

As it said its a invalid token

#

Great. Thank you for the help.

brittle ingot
#

it appears your token isn't making the typeof string. make sure you are storing it inside quotes

slate swan
slate swan
slate swan
brittle ingot
#

This is fine, im just sending that incase you didn't know it existed.

#

try logging token to the console.

slate swan
slate swan
boreal ravine
#

read the error

boreal ravine
#

Im stating facts

#

literal paywalls everywhere

slate swan
#

Trying to do "import discord" on line one and it says I have no module named discord.

sullen shoal
#

you didn't properly retrieve the environment variables then

sullen shoal
slate swan
sullen shoal
slate swan
#

Oh ok

sullen shoal
#

import disnake

boreal ravine
#

"big brain"

sullen shoal
slate swan
#

Nope

slate swan
#

Didnt work

boreal ravine
sullen shoal
#

alright you have two python installations

#

i heard macs have python2 installed by default

slate swan
brittle ingot
#

Vps's do though

slate swan
#

I did import disnake but it isnt working

sullen shoal
#

where filename is your file's name where you imported the module

slate swan
#

I only imported it into the terminal

sullen shoal
#

although i dont know why you as a beginner are starting with discord.py
the owner straight up claims, this is not beginner friendly.

#

and you will suffer alot

#

it has many advanced topics of python

#

you will need time to understand

#

you have to begin with small projects like calculator, tictactoe

slate swan
#

Ok but I will need to get this to work eventually, right?

#

I have done those projects

#

I am taking a python class in school and we have done those

#

We just do it on a website called codehs

sullen shoal
#

what about decorators, python classes, OOP

slate swan
#

no

slate swan
#

Like I just want to get this working. I may not start coding bots now but I just want it to work so later I can

#

I do stand for what you said but just let him be

sullen shoal
#

well i have been through that as a kid, i learnt nothing and it was a waste of 3 months

slate swan
#

We all dont make the same mistake

slate swan
#

Ehhh, my first dpy bot I knew nothing about OOP and decorators

#

It makes it a lot easier, but you learn from your mistakes

slate swan
slate swan
sullen shoal
#

okay pretty sure thats what going to happen but okay so the problem is that you have two python installations and the one where the modules are not installed has been selected by default

slate swan
sullen shoal
#

this will help with it.

brittle ingot
#

surprisingly many of us are self taught 😄

slate swan
slate swan
slate swan
#

Having problems thrown at you that you wouldn't necessarily tackle otherwise speeds up your learning so fast

#

So how do I get to the other python that has the thingss i installed

sullen shoal
#

i sent a link? @slate swan

slate swan
#

I wouldn't be decent at recursion if it didn't get shoved down my throat

wise tinsel
brittle ingot
slate swan
slate swan
slate swan
slate swan
#

Recursion was a nightmare topic, until it wasn't

slate swan
slate swan
slate swan
slate swan
wise tinsel
#

Why??

#

I mean

sullen shoal
#

you asked

brittle ingot
#

okay, just make sure you are out of your project directory to make sure run:

cd

then:

python3 -m pip install discord.py
wise tinsel
#

Why is it best??

slate swan
boreal ravine
brittle ingot
#

yes in your VSCode terminal

slate swan
sullen shoal
boreal ravine
wise tinsel
#

Slash commands??

slate swan
sullen shoal
#

yes those have been implemented

slate swan
wise tinsel
cerulean osprey
#

Hello again. I wanted to add something where, when my bot bans someone, it sends a message saying they were banned, this is the code I used

await message.channel.send(message.author , 'has been softbanned')

However I got an error saying TypeError: send() takes from 1 to 2 positional arguments but 3 were given how do I fix this?

brittle ingot
sullen shoal
#

Myxi#1818 | 19/11/21, 11:53:20 AM

yes those have been implemented

@wise tinsel

boreal ravine
#

use f-strings

slate swan
#

My VSCode terminal just has nothing happen

sullen shoal
slate swan
#

F strings are a gift

#

string concatenation is a nightmare

sullen shoal
#

f"{message.author} ..."

boreal ravine
#

% is best way to format

cerulean osprey
#

I got it 2DYayRainbow thank you

boreal ravine
#

😏

slate swan
slate swan
sullen shoal
#

two python installations. as i said

boreal ravine
slate swan
sullen shoal
#

i do think its good tho. % and .format string method have their uses that fstrings cant do

slate swan
#

I've never seen % used, so I was confused

sullen shoal
slate swan
#

Was it Python environments?

sullen shoal
#

yes

#

it will be showing diffrent installations if you click that

boreal ravine
unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

i love apples
boreal ravine
#

first generation of f-strings

slate swan
#

That just looks like shorthand for format lol

boreal ravine
#

yes

north quiver
#

hey, guys. Help with the error:

@Bot.command()
async def tempban(ctx, member: discord.Member, time=None, reason=None):
    if time == "s":
        await asyncio.sleep(time*1)

    if time == "m":
        await asyncio.sleep(time*60)

    if time == "h":
        await asyncio.sleep(time*60*60)

    if time == "d":
        await asyncio.sleep(time*60*60*24)

    await ctx.send(f"**{member.mention}, был забанен на - {d}**")
    embed = discord.Embed(
        title = "Вы были временно забаненны",
        color = 0x49ff00
        )
    embed.add_field(
        name = "Кто Вас временно забанил:",
        value = f"**{ctx.author} ({ctx.author.mention})**",
        inline = True
        )
    embed.add_field(
        name = "На сколько Вы были забанены:",
        value = f"{time}",
        inline = False
        )
    await member.send(embed=embed)

    await member.unban()
    emb = discord.Embed(
        title = "Вы были разбанены",
        color = 0x49ff00
        )
    emb.add_field(
        name = "Время бана:",
        value = f"{time}",
        inline = True
        )
    emb.add_field(
        name = "Причина:",
        value = f"{reason}",
        inline = False
        )
    await member.send(embed=emb)```
sullen shoal
#

error where

slate swan
#

share the traceback

sullen shoal
#

its ctx.send

slate swan
#

Oh yep

maiden fable
#

Ye. The last member.send won't work

#

Since the member won't be there in the guild

slate swan
#

You cant message a random user if you share no guilds with him its how discord works

maiden fable
#

Yea

slate swan
slate swan
sullen shoal
#

thats why you read before judging

slate swan
#

I did read

sullen shoal
#

anyways good luck

slate swan
#

I will probably be back soon because I am not so smart but thank you.

slate swan
sullen shoal
#

also check the examples in the repo for help

#

who is the someone

#

server owner?

slate swan
#

Pls elaborate

sullen shoal
#

gone

slate swan
#

oof

sullen shoal
#

i think even theyre confused about what they want

slate swan
#

so a command that tells you a user's information, similar to the ?info command in Carl bot?

sullen shoal
#

that can be achieved with different attributes of discord.User and discord.Member

slate swan
#

such as Member.created_at

#

Had a brain aneurysm

sullen shoal
#

the part that confused me the most was,

when I entered the server

slate swan
#

All of it

slate swan
#

It just wasnt in proper order and was misunderstood

#

A few commas would've helped lol

sullen shoal
#

i think now we are being very lifeless to talk about something so useless

slate swan
#

I'm always lifeless

wise tinsel
#

8s there a 24/7 free bot host

sullen shoal
#

maybe

slate swan
#

Idk, I just host my bot on an rpi

slate swan
wise tinsel
#

Not that

slate swan
wise tinsel
#

Not replit

slate swan
slate swan
#
@bot.command()
async def ping(ctx):
    await ctx.send('Pong! {0}'.format(round(bot.latency, 1)))

How do I pass a user ID or user @

So the command will be +ping @torn cape123123123test

slate swan
slate swan
sullen shoal
#

will you host someone's project you dont know, doesnt even pay 24/7? probably wont. so why would a hosting provider do that? i'd say just buy a cheap vps

slate swan
slate swan
slate swan
#

the command will just take +ping

#

I want it to take +ping then the @ user

#

I think its like on_member.mention idk please someone correct me

#

I don't think thats right

#

Its 2am my brain isnt quite working

slate swan
#
@bot.command()
async def ping(ctx, user):
    await ctx.send('Pong! {0}'.format(round(bot.latency, 1)))```
#

I think its closer to that

#

Can you elaborate

sullen shoal
#

typehint to discord.Member

slate swan
#

What are you looking for? The command caller?

#

I'm looking for the user to pass the command as well as an @
So the end-user should input: +ping @ user

#

Are you looking for a mention in a command i dont understand

sullen shoal
slate swan
#

alr lemme try

sullen shoal
#

or discord.User depends on what you want to do

slate swan
#

whats the difference?

boreal ravine
sullen shoal
#

you cant do the actions of banning, add roles and stuff

slate swan
slate swan
#

I usually use Member objects so that I can use their display name

sullen shoal
#

in a userinfo command tho, using Union is better. the command will be more powerful

sullen shoal
#

by powerful, I meant that you can show avatar, name and creation date and some other stuff of people you dont know

slate swan
boreal ravine
slate swan
#

Well that messes with me

boreal ravine
#

!e

from typing import Union

def string(text: Union[str, int]):
  return text * 5

print(string("h"))
``` i have no experience with typing
unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

hhhhh
sullen shoal
slate swan
#

Ah so basically saying it can be a str or a int or None

#

Oh, its just a type hint

#

nvm, not confusing

slate swan
sullen shoal
#

discord.py tried to convert the parameter to the typehint if available otherwise it will pass the string to the param.
if you use Union (or the | if 3.10) it will try to convert to any of the given types, like

async def command(user: Union[discord.Role, discord.Member])```
here discord.py will first try to convert the argument to Role if successful it will continue but if not it wil convert to the next type given
#

if both fail it will raise error

slate swan
#

Oh, thats interesting

#

I dunno if I'd write it like that tho, I like knowing exactly what type I'm dealing with at all times

slate swan
#

I probably will never use it, but its cool information

boreal ravine
#

Whats | in python

#

Never heard of it in python, only in some other languages

sullen shoal
#

same as typing.Union

slate swan
#

I thought it was bitwise or

boreal ravine
#

typing.Union isn't needed anymore then?

sullen shoal
#

if 3.10 yes

slate swan
#
user:discord.User

this returns [<User id=477266267175256125 name='Neth' discriminator='6000' bot=False>]
Any way for it to return just the ID

sullen shoal
#

bitwise or is || iirc

slate swan
#

is that just .id?

boreal ravine
unkempt canyonBOT
slate swan
#

alr ty

boreal ravine
slate swan
#

Gn guys

unkempt canyonBOT
#

Hey @hushed siren!

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

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

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

https://paste.pythondiscord.com

sullen shoal
hushed siren
#

i cant send message up to 2k messages

slate swan
#

Gn!

sullen shoal
#

gn

boreal ravine
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.

slate swan
boreal ravine
#

gn

hushed siren
#

but the bot deleted it

#

okay anyways here is my problem

#

so im trying to make an reaction role command and everything works fine but when its time to give me the role it gives me this error:

File "main.py", line 133, in on_raw_reaction_add
    await payload.member.add_roles(role)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/member.py", line 777, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'

and here is the code:
https://paste.pythondiscord.com/iqakuhuyij.sql

sullen shoal
#

role is None

#

uh ngl the website's theme is really bad

hushed siren
#

yea its kinda blue and kinda green

boreal ravine
sullen shoal
#

i have

slate swan
#

This is why I don't miss prefix commands

#

string manipulation is a hassle

hushed siren
slate swan
#

Hmmmm, tbh idk dpy enough to help

#

I'd test with checking the object type of role

#

raise UserNotFound(argument) discord.ext.commands.errors.UserNotFound: User "asdasd" not found.

How am I able to inform the user that they have entered invalid syntax / the wrong user?

#

is that just error hadnling?

sullen shoal
slate swan
#

ty

hushed siren
#

but not the role

slate swan
#

check the type of the role object

hushed siren
#

okay

bright palm
slate swan
#

and check the name of selected_role so that you know you've done your string formatting right

sullen shoal
slate swan
#

Hey

#

can u help me if u are experienced

keen talon
#

just ask

#

😬

slate swan
#

I need like the bot to give a role if someone says the line -"I am a fool"

#

If he says that he should be given the fool role which i have made

keen talon
#

use on_message event

#

what lib are you using

sullen shoal
#

!d discord.on_message

unkempt canyonBOT
#

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

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

Warning

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

can u tell the script

#

i am kinda new

sullen shoal
#

no spoonfeed

slate swan
slate swan
keen talon
#

how do I hide a command from the help command, I used hidden=True , is_hidden=True but it didn't work

sullen shoal
#

!d discord.ext.commands.Bot.help_command

unkempt canyonBOT
sullen shoal
#

not recommended.

keen talon
#

!d discord.ext.commands.command

unkempt canyonBOT
#

@discord.ext.commands.command(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or if called with [`group()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.group "discord.ext.commands.group"), [`Group`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group").

By default the `help` attribute is received automatically from the docstring of the function and is cleaned up with the use of `inspect.cleandoc`. If the docstring is `bytes`, then it is decoded into [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") using utf-8 encoding.

All checks added using the [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") & co. decorators are added into the function. There is no way to supply your own checks through this decorator.
sullen shoal
slate swan
#

@sullen shoalcan u plz tell the script

sullen shoal
#

one of them showcases it

sullen shoal
keen talon
#

the command still shows up

sullen shoal
#

show me what you did

keen talon
#
@commands.command(aliases=('close',), hidden=True)
    @commands.is_owner()
    async def stop(self, ctx):
        """Make the bot go offline"""
        await ctx.send(embed=nextcord.Embed(description="**Closing bot in 1 sec**", colour=nextcord.Colour.random()))
        time.sleep(1)
        await self.Intensity.close()
sullen shoal
#

:/

keen talon
#

wit , I will check the repo once

slate swan
#

is there a way to make python tts bot with your own voice

boreal ravine
keen talon
keen talon
sullen shoal
slate swan
#

text to speech

#

yes

keen talon
slate swan
#

yes you can

sullen shoal
keen talon
sullen shoal
#

thats it

slate swan
#

how do you know @sullen shoal

sullen shoal
#

its possible

slate swan
#

do you have any code