Skip to content

Instantly share code, notes, and snippets.

View itsmefox's full-sized avatar
🦊
If you can be a Fox

itsmefox itsmefox

🦊
If you can be a Fox
View GitHub Profile
@itsmefox
itsmefox / psql_useful_stat_queries.sql
Created December 12, 2022 14:25 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@itsmefox
itsmefox / BotReadyListener.kt
Last active November 25, 2022 10:29
Create your Discord Bot with aluna-spring-boot-starter - BotReadyListener
@Component
class BotReadyListener : ApplicationListener<DiscordFirstShardReadyEvent> {
override fun onApplicationEvent(event: DiscordFirstShardReadyEvent) {
//Set the status of the bot as soon as possible
event.shardManager.setPresence(OnlineStatus.ONLINE, Activity.playing("I'm Ready"))
}
}
@itsmefox
itsmefox / PingCommand.kt
Created November 24, 2022 16:05
Create your Discord Bot with aluna-spring-boot-starter - PingCommand
@Interaction
class PingCommand : DiscordCommand("ping", "Send a ping command") {
override fun execute(event: SlashCommandInteractionEvent) {
//Reply to the user
val startTime = System.currentTimeMillis()
event.reply("Ping ...").setEphemeral(true).queue {
it.editOriginal("Pong: ${System.currentTimeMillis() - startTime}ms").queue()
}
}
@itsmefox
itsmefox / aluna-log-output.txt
Last active November 24, 2022 15:47
Create your Discord Bot with aluna-spring-boot-starter - log output 1
_ _ ____ _ _ ____ _
/ \ | |_ _ _ __ __ _ | _ \(_)___ ___ ___ _ __ __| | | __ ) ___ | |_
/ _ \ | | | | | '_ \ / _` | | | | | / __|/ __/ _ \| '__/ _` | | _ \ / _ \| __|
/ ___ \| | |_| | | | | (_| | | |_| | \__ \ (_| (_) | | | (_| | | |_) | (_) | |_
/_/ \_\_|\__,_|_| |_|\__,_| |____/|_|___/\___\___/|_| \__,_| |____/ \___/ \__|
Aluna: 0.0.32_5.0.0-alpha.22-SNAPSHOT
Spring-Boot: 2.7.0
JDA: 5.0.0-alpha.22
@itsmefox
itsmefox / application.yaml
Created November 24, 2022 15:39
Create your Discord Bot with aluna-spring-boot-starter - application.yaml
aluna:
discord:
application-id:
token:
logging:
level:
io.viascom.discord.bot.aluna.AlunaAutoConfiguration: DEBUG
io.viascom.discord.bot.aluna.SlashCommandInteractionInitializer: DEBUG
io.viascom.discord.bot.aluna.ListenerRegistration: DEBUG
@itsmefox
itsmefox / BotApplication.kt
Created November 24, 2022 15:08
Create your Discord Bot with aluna-spring-boot-starter - Application
@SpringBootApplication
open class BotApplication {
companion object {
@JvmStatic
fun main(args: Array<String>) {
runApplication<BotApplication>(*args)
}
}
}
@itsmefox
itsmefox / PingCommand.java
Last active November 23, 2022 16:04
Creating a Discord Bot with Kotlin - PingCommand
public class PingCommand extends ListenerAdapter {
private Logger logger = LoggerFactory.getLogger(this.getClass());
//This gets called when a slash command gets used.
@Override
public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) {
//Check if this is our /ping command
if (event.getName().equals("ping")) {
logger.info("Command /ping got used");
@itsmefox
itsmefox / Application.java
Created June 22, 2022 12:32
Creating a Discord Bot with Kotlin - Application - 2
public class Application {
public static void main(String[] args) throws LoginException {
String token = "";
//Create a new JDA instance
JDA jda = JDABuilder.createDefault(token)
.addEventListeners(new PingCommand()) //Register our /ping Command
.build();
@itsmefox
itsmefox / Application.java
Created June 22, 2022 12:30
Creating a Discord Bot with Kotlin - Application - 1
public class Application {
public static void main(String[] args) throws LoginException {
String token = "";
//Create a new JDA instance
JDA jda = JDABuilder.createDefault(token).build();
//Set the activity to "I'm Ready"
jda.getPresence().setActivity(Activity.playing("I'm Ready"));
@itsmefox
itsmefox / PingCommand.kt
Last active November 23, 2022 16:08
Creating a Discord Bot with Kotlin - PingCommand
class PingCommand : ListenerAdapter() {
private val logger: Logger = LoggerFactory.getLogger(javaClass)
//This gets called when a slash command gets used.
override fun onSlashCommandInteraction(event: SlashCommandInteractionEvent) {
//Check if this is our /ping command
if (event.name == "ping") {
logger.info("Command /ping got used")