play static method
Implementation
static Future<String> play(CommandContext ctx) async {
if (ctx.args.isEmpty) {
return '❌ Please provide a song name or URL!';
}
final query = ctx.args.join(' ');
final client = ctx.client;
// Join voice channel
await client.joinVoiceChannel(
guildId: ctx.guildId,
channelId: ctx.channelId,
);
// Search for tracks
final result = await client.loadTracks(query);
if (result.tracks.isEmpty) {
return '❌ No tracks found!';
}
final track = result.tracks.first;
await client.play(ctx.guildId, track);
return '🎵 Now playing: **${track.info.title}** by ${track.info.author}';
}