Merubokkusu / Discord-S.C.U.M

A Discord API Wrapper for Userbots/Selfbots written in Python.
MIT License
588 stars 167 forks source link

Send slash command #411

Open KumaHugg opened 2 years ago

KumaHugg commented 2 years ago

Hi,does anyone know how to send slash command in channel? I try triggerslashcommand but not work(I don't know to code) pls send me code for send slash command(for example:channelId='10001',botId='111000',token='plshelp')

tanersb commented 2 years ago

@KumaHugg https://github.com/Merubokkusu/Discord-S.C.U.M/blob/master/examples/slashcommands.py

SimonNordon4 commented 2 years ago

slashCmds = bot.getSlashCommands(botID).json() from discum.utils.slash import SlashCommander s = SlashCommander(slashCmds) data = s.get(['name_of_the_slash_command'], inputs={'name_of_the_options_in_the_slash_command':'the_options_input'}) bot.triggerSlashCommand(botID,channelID=channelID,guildID=guildID, data=data)

The first 3 lines of the code is retrieving and parsing the slash command options. line 4 allows you to retrieve slash commands and send them.

For example if the slash command is "info" and takes no arguments then data = s.get(['info'])

If the slash command is "imagine" and takes the argument "prompt" then data = s.get(['imagine'], inputs={'prompt':'this is an example prompt'})

This gives you the data in a way the api will accept. Finally you just need the bot ID you're trying to trigger, the guild id and the channel id.