Bot Development
need some help if possible, I've set up a bot using Discord API, invited it to my server but haven't been able to set up basic commands yet. how do i do this?
32 Replies
First, the problem may be that you dpnt have discordpy. Run this command in the terminal or enviroment. Use cd to navigate folders.
pip install -U discord.py
Second, In your code, enable intents.
import discord
intents = discord.Intents.default()
intents.message_content = True
Also, make sure to enable the Message Content Intent in the Discord Developer Portal.
Then create the Bot Instance
Setup the bot with command prefix
from discord.ext import commands
bot = commands.Bot(command_prefix='Your prefix, :, ?...', intents=intents)
Also define Commands
Example of a ping:
@bot.command()
async def ping(ctx):
await ctx.send('Pong!')
Last, run your bot.
bot.run('YOUR_BOT_TOKEN')so with the command instance, if i want the bot to, let's say pull up a Spotify playlist, how would this get coded
also very dumb question but I'm new to Python, i assume I will need to have python for all this to work?
Yeah.
Discordpy its a dependency.
You can download lastest version here
gotcha, so open Python and run the first command you mentioned and follow from there?
Also, I dont get ya.
Can you elaborate?
Yeah, but run in in the terminal or enviroment youre using.
Python is an executable. It will install itself.
so, the way I want the bot to run is to display in game times of a game, display events for said game as well as patch notes. a lot of that work load will require weblinks and integrations that I am aware that other bots already have (mainly PatchBot) but i want a lesser version for my own server (if that makes sense)
Um.
Hold on, im trying to process your message 😭
you're all good
would it help if I get the websites for a more visual representation?
I just dont get it.. Like.
Sure
Alright so
You told me you wanna get a spotify song or smth?
yeah no absolutely ignore that, just an example I tried using haha
this is one of the sites
https://gtalens.com/weather
Okay
And you want to...?
have the bot display the time from that site
Ohhh alright
Hit an API endpoint (or scrape a webpage if there's no API), grab the JSON or HTML, format the info, and send it back as a message or embed. Could be something like !gametimes.
Is that what you were lookign for or..?
oh right okay, yeah sorta. Just tryna put how I'd make it all work together. I'll have a play in python and see what I can configure. I seriously appreciate your help!!!
Yeah! Happy to help!
If you need something else, try looking https://discordpy.readthedocs.io/en/stable/
https://discordpy.readthedocs.io/en/stable/ext/commands/index.html
that'll help a lot, thank you so much!!! ill post updates when I've played around
Great!
Have fun!
update, coded the bot, got it to come online, appear in the server and use basic slash commands. having a bit of teething issues with making the bot reply to regular messages but thats a tomorrow job!

Nice!
the flag to add to the command file is ephemeral: true
if you mean that, I hope I understood correctly!
To do that, you would need to interact with the spotify API. Personally I've only used the youtube API, so I have no idea. First learn the basics off bot development :D
im not sure i understand, could you elaborate?
ill have a little look at videos and if it's been done before, like you said, just practicing and learning at the moment
await interaction.response.send_message("-your message-", ephemeral=True)
ohhhh is this for the bot response without commands?
This will make it only so the original user who made the command can see it.,
ooh okay gotcha thanks!!
Sorry my friend I just saw your message but @Wicks told you everything! Good job!