TheMk1Pro
TheMk1Pro5d ago

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
NotYourBusiness.
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')
TheMk1Pro
TheMk1ProOP5d ago
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?
NotYourBusiness.
Yeah. Discordpy its a dependency. You can download lastest version here
NotYourBusiness.
Python.org
Download Python
The official home of the Python Programming Language
TheMk1Pro
TheMk1ProOP5d ago
gotcha, so open Python and run the first command you mentioned and follow from there?
NotYourBusiness.
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.
TheMk1Pro
TheMk1ProOP5d ago
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)
NotYourBusiness.
Um. Hold on, im trying to process your message 😭
TheMk1Pro
TheMk1ProOP5d ago
you're all good would it help if I get the websites for a more visual representation?
NotYourBusiness.
I just dont get it.. Like. Sure Alright so You told me you wanna get a spotify song or smth?
TheMk1Pro
TheMk1ProOP5d ago
yeah no absolutely ignore that, just an example I tried using haha
TheMk1Pro
TheMk1ProOP5d ago
this is one of the sites https://gtalens.com/weather
This tool aims to give you a complete information on the current and future weather in GTA Online which is possible to obtain due to the fact that the weather goes through the predictable cycle and thus can be precisely predicted.
NotYourBusiness.
Okay And you want to...?
TheMk1Pro
TheMk1ProOP5d ago
have the bot display the time from that site
NotYourBusiness.
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..?
TheMk1Pro
TheMk1ProOP5d ago
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!!!
NotYourBusiness.
Yeah! Happy to help!
TheMk1Pro
TheMk1ProOP5d ago
that'll help a lot, thank you so much!!! ill post updates when I've played around
NotYourBusiness.
Great! Have fun!
TheMk1Pro
TheMk1ProOP4d ago
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!
TheMk1Pro
TheMk1ProOP4d ago
No description
NotYourBusiness.
Nice!
! Smokey
! Smokey3d ago
the flag to add to the command file is ephemeral: true if you mean that, I hope I understood correctly!
Wicks
Wicks2d ago
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
TheMk1Pro
TheMk1ProOP2d ago
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
Wicks
Wicks2d ago
await interaction.response.send_message("-your message-", ephemeral=True)
TheMk1Pro
TheMk1ProOP2d ago
ohhhh is this for the bot response without commands?
Wicks
Wicks2d ago
This will make it only so the original user who made the command can see it.,
TheMk1Pro
TheMk1ProOP2d ago
ooh okay gotcha thanks!!
! Smokey
! Smokey2d ago
Sorry my friend I just saw your message but @Wicks told you everything! Good job!

Did you find this page helpful?