discord

Discord bot youtube search, wait for answer of asynchronous function

一世执手 提交于 2021-01-29 09:31:08
问题 I have built a discord but using javascript I've got one command where I want the ability to search for a youtube video and play the first result in a voice channel. I'm using the discordjs and discord-youtube-api libraries. This code looks for the command to search. The args array is the search query else if (command === 'search') { isReady = false; if (message.channel.type !== 'text') return; const { voiceChannel } = message.member; if (!voiceChannel) { return message.reply('please join a

Discord.py-rewrite - How to make the BOT self mute or self deaf in a voice channel?

有些话、适合烂在心里 提交于 2021-01-29 08:30:45
问题 I am making a Discord BOT using discord.py-rewrite and am focusing on the Music part of my BOT. I checked the API several times but I do not know how to make my self mute or self deaf on a voice channel (not server mute or server deafen). Anyone please know how I can self mute or self deaf my discord BOT? 回答1: It looks like the API doesn't expose this functionality, but there is a method for doing this in the websocket code @bot.command() async def mute(ctx): voice_client = ctx.guild.voice

my function on_member_join(member) is never called

寵の児 提交于 2021-01-29 08:18:28
问题 i'm doing a discord bot (python 3.8.6). My function on_ready(): is functional, same for my function "say_hello" But i don't know why, discord never detects on_member_join(member) bot = commands.Bot(command_prefix =".", description = "yolooooooooooooooooooooooooooooo") #prints 'logged on' when bot is ready @bot.event async def on_ready(): print('logged on salaud') @bot.event async def on_member_join(member): embed=discord.Embed(title=f"Welcome To Mafia Server, Be carefully or you will die",

Making a discord bot that takes a screenshot every 5 minutes and posts it to a specific channel. I'm newer and not really sure what to do next

☆樱花仙子☆ 提交于 2021-01-29 08:08:10
问题 I'm making a discord bot that would take a screenshot of my screen, then post it to discord, and repeat this task every 5 minutes. It seems pretty simple, but I'm pretty new, and have been doing research and not really sure at this point what I've done wrong. import discord import pyautogui import time import datetime class MyClient(discord.Client): async def on_ready(self): print('Logged on as', self.user) if datetime.datetime.now().minute % 5 == 0: myScreenshot = pyautogui.screenshot()

MySQL turns itself off after discord bot left on for about 12 hours

一世执手 提交于 2021-01-29 07:26:08
问题 I'm hosting a discord.js bot on an ubuntu VPS, and the bot uses MySQL as its database. I turn on the bot, and leave it, and it works fine, but after about 12 hours (it tends to vary), the bot goes offline, because of an error, saying MySQL server disconnected. But, if I restart the bot, MySQL turns back on, and bits of the bot that require the database use the database perfectly fine. I'm not sure if this is an error with MySQL, Node.JS or Ubuntu, but I don't know how to fix it. Thanks! 回答1:

How to make give role on_message in discord.py?

馋奶兔 提交于 2021-01-29 07:21:05
问题 I want the bot to give role to users if they mentions three people in a specific channel , I want to do this with 2 channels and role for both channels are different, code: @client.event async def on_message(message): if message.channel.id == 724969989777522778: try: if len(message.mentions) >= 3: await message.add_reaction(emoji="<a:tick:748476262640779276>") role = discord.utils.get(message.guild.roles, name="CUSTOM 3pm") user = message.author await user.add_roles(role) #await.message.add

Disable discord.py command at certain times of day

南笙酒味 提交于 2021-01-29 06:44:52
问题 I have a tts bot that I want to either toggle on and off with a command, or be automatically turned of from 11pm - 7am when i'm sleeping. Is this possible? TTS Code: @client.command() async def tts(ctx, *, msg): print('{0} : {1}'.format(ctx.author, msg)) print('TTS started {}'.format(msg)) os.system('flite -t "{}"'.format(msg)) await ctx.send('TTS done.') 回答1: You can make a loop, that iterates every 24 hours that will change the enabled_tts variable to False, in the command, check if the

Command cooldown in discord.py

我的未来我决定 提交于 2021-01-29 06:36:01
问题 I want commands for my discord bot to have cooldowns. I've tried other methods, but none of them seemed to work for what I have. @client.event async def on_message(message): if message.content == 'shear sheep': await message.channel.send('you sheared your sheep, gaining 1 wool.') #cooldown? 回答1: I would suggest using a variable to track weather the command has been used or before the cooldown. import time cooldown = True @client.event async def on_message(message): global cooldown if message

bot counting command discord

ぃ、小莉子 提交于 2021-01-29 04:56:05
问题 I have a private bot on discord, i've been trying to make him count a command and adding '+1' everytime I write that one command but it stays at 1 and can't go further : like this I think what I want to do is to make it save the number of time the command has been writen and add +1 to this number ; Should I do a loop or something ? Basically what I want is something like this in python for a discord bot : https://docs.nightbot.tv/commands/variables/count 回答1: You're resetting your counter

Discord.JS | Getting channel object returns undefined

£可爱£侵袭症+ 提交于 2021-01-29 04:17:23
问题 I have some issues understanding the Discord.JS module, I have no clue of how to connect my bot to a server, even after looking at a lot of documentaries! var Discord = require ( 'discord.js' ), Client = new Discord.Client ( ); Client.on ( 'ready', () => { console.log ( Client.channels.get ( '***ChannelID***' ) ); }); Client.login ( '***TOKEN***' ); Output : undefined Where getting the channel returns undefined even I pass the correct id. I don't know if the bot can connect to it without