You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromdiscord.extimportcommandsimportdiscordfromasyncioimportrunbot=commands.Bot(
command_prefix='e!',
intents=discord.Intents.all()
)
@bot.command()asyncdefhi(ctx):
awaitctx.send(f'Hello, {ctx.author}!')
@bot.command()asyncdefping(ctx):
awaitctx.send(f'Pong! {round(bot.latency*1000)}ms.')
# this is where dshell stuff starts run(bot.load_extension('dshell'))
bot.dshell_config['shell_channels'] = [930143692545744896, 808404030380441600] # put your own channel IDs here. all the channels that you've put will become shell channelsbot.dshell_config['shell_in_dms'] =Truebot.dshell_config['give_clear_command_confirmation_warning'] =False# after you're done with whatever configuration you had to do, run the botbot.run(TOKEN_GOES_HERE)
A bot specifically dedicated to DShell, whose only purpose is to serve as a shell bot
fromdiscord.extimportcommandsfromdiscordimportIntentsfromasyncioimportrunbot=commands.Bot(
command_prefix='s!',
intents=Intents.all()
)
run(bot.load_extension('dshell'))
bot.dshell_config['shell_channels'] = [930143692545744896, 808404030380441600] # again, use your own channel IDsbot.dshell_config['shell_in_dms'] =Truebot.run(TOKEN_GOES_HERE)
A typical public multipurpose bot with cogs
importdiscordimportasynciofromdiscord.extimportcommands, tasksfromosimportlistdirfrombot_configimportBotHelpCommand, get_prefix, TOKENbot=commands.Bot(
command_prefix=get_prefix,
help_command=BotHelpCommand(),
description='A multipurpose bot that can do anything your heart desires!',
intents=discord.Intents.all(),
allowed_mentions=discord.AllowedMentions(roles=False, everyone=False),
case_insensitive=True,
strip_after_prefix=True,
owner_ids= [123123, 6969420]
)
@tasks.loop()asyncdefchange_statuses():
statuses= [
f'with {len(bot.guilds)} servers | s!help',
f'with {len(bot.users)} users | s!help',
'with everything that you can ever want! | s!help'
]
forstatusinstatuses:
awaitbot.change_presence(activity=discord.Game(name=status))
awaitasyncio.sleep(60)
@change_statusesasyncdefbefore_change_statuses():
awaitbot.wait_until_ready()
asyncdefload_extensions:
forcoginlistdir('cogs'):
awaitbot.load_extension(f'cogs.{cog[:-3]}') #:-3 to remove the .py extensionawaitbot.load_extension('dshell')
asyncio.run(load_extensions())
bot.dshell_config['shell_channels'] = [930143692545744896, 808404030380441600]
bot.run(TOKEN)
These are only examples for you to get a basic idea of how to implement dshell into your bot. This is not a hard set of rules and you can change this according to your needs.