var serverConfigurations = File.ReadAllText("E:\\C#\\DiscordBot\\servers.json");
var json = JsonConvert.DeserializeObject<dynamic>(serverConfigurations);
//Путь к переменной. Вывод:
Console.WriteLine(json._905391627751784458.CommandConfigurations.Ping.Embed1.WithFooter.Text.user_id)
from discord.ext import commands
intents = discord.Intents.all()
command_prefix = "!"
bot = commands.Bot(
command_prefix = command_prefix,
intents = intents,
help_command = None
)
COMMANDS = [
"refresh"
]
@bot.event
async def on_message(message):
if (message.author == bot.user):
return
elif (message.content.startswith(command_prefix)):
if (message.content in command_prefix + COMMANDS):
pass
else:
response = get_city(message.content)
await message.channel.send(response)
@bot.command()
async def refresh(ctx):
refresh()
bot.run(TOKEN)
import discord
from discord.ext import commands
bot = commands.Bot(intents = discord.Intents.all)
class MyModal(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label = "Short Input"))
self.add_item(discord.ui.InputText(
label = "Long Input",
style = discord.InputTextStyle.long)
)
async def callback(self, interaction: discord.Interaction):
embed = discord.Embed(title="Modal Results")
embed.add_field(name = "Short Input", value = self.children[0].value)
embed.add_field(name = "Long Input", value = self.children[1].value)
await interaction.response.send_message(embeds=[embed])
@bot.slash_command()
async def modal_slash(ctx):
modal = MyModal(
title = "Modal"
)
await ctx.send_modal(modal)
bot.run(TOKEN)
MODAL DOCS
MODAL VIDEO
@bot.command()
async def get_name(ctx, member: discord.Member = None):
if member is None:
member = ctx.author
await ctx.reply(
f"Ник без ID: {member.name},\nНик как на сервере, где была использована команда: {member.guild.name},\nПолный ник (с ID): {member}."
)
@client.command()
async def auto_send():
channel = await client.get_channel("channel_id")
while True:
await channel.send("message_1")
await asyncio.sleep(604800) # Неделя
await channel.send("message_1")
await asyncio.sleep(604800)
@client.command(aliases = ["идея", "ИДЕЯ", "IDEA"])
@commands.cooldown(1, 60, commands.BucketType.user)
async def idea(ctx, *, idea = None):
role = discord.utils.find(lambda r: r.name == f"АДМИН", ctx.message.guild.roles)
if role in ctx.author.roles:
ctx.commands.reset_cooldown()
await ctx.message.delete()
await ctx.send("Ваша идея отправлена разработчикам.")
await client.get_channel(settings['ADMINCHAT']).send(f"<@&{(settings['DEVELOPERROLE'])}> Идея от {ctx.author}: \"{(idea)}\"")
print(f'{ctx.author} || {ctx.author.id} отправил идею: \"{(idea)}\"')
@bot.command()
@commands.cooldown(1, 86400, commands.BucketType.user)
async def бонус(ctx):
await open_acc(ctx.author)
users = await get_bank()
await ctx.reply("Выдан бонус! +1 монета")
users[str(ctx.author.id)]["wallet"] += 1
with open("mainbank.json", "w") as f:
json.dump(users, f)