Solved.
rs = RiveScript(utf8=True) # open rivescript; we can also change encoding if we want to use foreign language with special characters
rs.load_directory(”./brain”) # just a path to our brain directory
rs.sort_replies()
@client.event
async def on_message(message):
if not (message.author == client.user): # Check to ensure the bot does not respond to its own messages
if (message.mention_everyone == False):
if (client.user.mentioned_in(message) or isinstance(message.channel, discord.abc.PrivateChannel)): # Check if the bot is mentioned or if the message is in DMs. Please note that the bot replies to private messages, you need to change this line if you want to use it on public channel
async with message.channel.typing(): # Show that the bot is typing
else:
msg = message.content # this is important part from this point to the end of script, we join the way how RiveScript and Discord take input and give a response
reply = rs.reply(“localuser”, msg)
await asyncio.sleep(random.randint(0, 2)) # not necessary, it just a simulation that the bot is typing a message and it takes some random time
await message.channel.send(reply)