up db test
This commit is contained in:
2
.idea/discord-bot.iml
generated
2
.idea/discord-bot.iml
generated
@@ -4,7 +4,7 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.9 (discord-bot)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
1
.idea/encodings.xml
generated
1
.idea/encodings.xml
generated
@@ -2,5 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/sqlite_python.db" charset="windows-1251" />
|
||||
<file url="file://$PROJECT_DIR$/test_database.sql" charset="windows-1251" />
|
||||
</component>
|
||||
</project>
|
||||
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -1,4 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (discord-bot)" project-jdk-type="Python SDK" />
|
||||
<component name="PyPackaging">
|
||||
<option name="earlyReleasesAsUpgrades" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
BIN
audio/1.mp3
BIN
audio/1.mp3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
72
main.py
72
main.py
@@ -1,32 +1,74 @@
|
||||
import random
|
||||
import sys
|
||||
import threading
|
||||
import logging
|
||||
import discord
|
||||
import ffmpeg
|
||||
from discord import guild, FFmpegPCMAudio
|
||||
from asyncio import sleep
|
||||
from os import walk
|
||||
|
||||
from discord import user, member
|
||||
from discord import FFmpegPCMAudio
|
||||
from discord.ext import commands
|
||||
|
||||
threading.current_thread().name = "main"
|
||||
logging.basicConfig(stream=sys.stdout, filemode='w', level='INFO',
|
||||
format='%(asctime)s - %(levelname)s - %(threadName)s - %(message)s')
|
||||
|
||||
bot = commands.Bot(command_prefix='$')
|
||||
|
||||
intents = discord.Intents.all()
|
||||
intents.typing = True
|
||||
intents.presences = True
|
||||
|
||||
bot = commands.Bot(command_prefix='$', guild_subscriptions=True, intents=intents)
|
||||
f = []
|
||||
for filenames in walk('audio'):
|
||||
f.extend(filenames)
|
||||
break
|
||||
f = f[2]
|
||||
|
||||
|
||||
@bot.event
|
||||
async def on_voice_state_update(member, before, after):
|
||||
channel = bot.get_channel(947075464256712724)
|
||||
print(member)
|
||||
_memb = 260050236813082624
|
||||
if before.channel == None:
|
||||
await channel.send(f'{member.mention} ах ты ебаглаз')
|
||||
voice_client: discord.VoiceClient = discord.utils.get(bot.voice_clients, guild=guild)
|
||||
audio_source = FFmpegPCMAudio('audio/1.mp3')
|
||||
if not voice_client.is_playing():
|
||||
voice_client.play(audio_source, after=None)
|
||||
if after.channel == None:
|
||||
await channel.send(f'{member.mention} ты куда пошел?')
|
||||
channel = bot.get_channel(783729824896122930)
|
||||
_role = 929729495370461205
|
||||
_memb = 375664768087752714
|
||||
_bot_id = 946819004314570852
|
||||
role = discord.utils.find(lambda r: r.name == 'тарковчане', member.roles)
|
||||
if before.channel is None and role in member.roles:
|
||||
track = random.randint(0, len(f) - 1)
|
||||
audio_source = FFmpegPCMAudio(f'audio/{f[track]}')
|
||||
logging.error(f'{track}\t\t\t{f[track]}')
|
||||
if not bot.voice_clients:
|
||||
await sleep(1)
|
||||
_channel = after.channel
|
||||
vc = await after.channel.connect()
|
||||
if not vc.is_playing():
|
||||
vc.play(audio_source, after=None)
|
||||
while vc.is_playing():
|
||||
await sleep(0.5)
|
||||
await sleep(1)
|
||||
await vc.disconnect()
|
||||
if before.channel is None and member.id == _memb:
|
||||
track = random.randint(0, len(f) - 1)
|
||||
audio_source = FFmpegPCMAudio(f'audio/{_memb}/bear2_enemy_scav3.wav')
|
||||
logging.error(f'{track}\t\t\t{f[track]}')
|
||||
if not bot.voice_clients:
|
||||
await sleep(1)
|
||||
_channel = after.channel
|
||||
vc = await after.channel.connect()
|
||||
if not vc.is_playing():
|
||||
vc.play(audio_source, after=None)
|
||||
while vc.is_playing():
|
||||
await sleep(0.5)
|
||||
await sleep(1)
|
||||
await vc.disconnect()
|
||||
|
||||
|
||||
@bot.event
|
||||
async def on_member_join(member):
|
||||
role = discord.utils.get(member.guild.roles, id=734358428939452486)
|
||||
print(role)
|
||||
await member.add_roles(role)
|
||||
|
||||
|
||||
@bot.event
|
||||
@@ -35,5 +77,3 @@ async def on_ready():
|
||||
|
||||
|
||||
bot.run('OTQ2ODE5MDA0MzE0NTcwODUy.YhkP6Q.dhFqi2MJMrxzHt5FtjK5Cl-5BI8')
|
||||
|
||||
# if __name__ == '__main__':
|
||||
|
||||
BIN
sqlite_python.db
BIN
sqlite_python.db
Binary file not shown.
Reference in New Issue
Block a user