Discord calculation bot command
############# BOT calculator #################
#-------------------------------------------------
import operator
action = {
"+": operator.add,
"-": operator.sub,
"/": operator.truediv,
"*": operator.mul,
"**": pow
}
print(action['-'](50, 15)) # 35
@bot.command(name='c')
async def calculator(ctx, arg1, arg2, arg3):
calcresult = action[arg2](arg1, arg3)
await ctx.send('---CALCULATION---')
await ctx.send(calcresult)
await ctx.send('---CALCULATION---')
############# BOT calculator #################
не работает калькулятор бот в дискорде L*(
Ответы (1 шт):
Автор решения: Jack Owest
→ Ссылка
У вас пропущены библиотеки "discord" и "commands" из "discord.ext"
import discord
from discord.ext import commands
А так же не объявлен и не запущен сам бот:
bot = discord.Client()
bot.run('BOT_TOKEN')
Полный код:
############# BOT calculator #################
#-------------------------------------------------
import operator
import discord
from discord.ext import commands
action = {
"+": operator.add,
"-": operator.sub,
"/": operator.truediv,
"*": operator.mul,
"**": pow
}
print(action['-'](50, 15)) # 35
bot = discord.Client()
bot.run('BOT_TOKEN')
@bot.command(name='c')
async def calculator(ctx, arg1, arg2, arg3):
calcresult = action[arg2](arg1, arg3)
await ctx.send('---CALCULATION---')
await ctx.send(calcresult)
await ctx.send('---CALCULATION---')
############# BOT calculator #################